<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>门店列表</title>
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="user-scalable=yes">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{{asset('/layuiadmin/layui/css/layui.css')}}" media="all">
    <link rel="stylesheet" href="{{asset('/layuiadmin/style/admin.css')}}" media="all">
    <style>
        .edit{background-color: #ed9c3a;}
        .shenhe{background-color: #4e7af5;}
        .see{background-color: #7cb717;}
        .tongbu{background-color: #4c9ef8;color:#fff;}
        .cur{color:#00BFFF;}
        .manage{background-color:#6c8ff5;}
        .water{background-color:#5fb878;}j
                                         .branchshop{background-color: #11d0be}
        .storecode{background-color: #4fd9e0;}
        #code{width: 190px;margin-right:10px;height: 190px;margin-right:10px;margin: 20px auto;}
        #code canvas{width: 100%;}
        .box .layui-btn{margin-bottom:10px;}
        .merchantmanage{background-color: #11d0be}
        .fuyoumanage{background-color: #9ad011}
        .userbox{
            height:190px;margin-right:10px;
            overflow-y: auto;
            z-index: 999;
            position: absolute;
            left: 0px;
            top: 60px;
            width:298px;
            background-color:#ffffff;
            border: 1px solid #ddd;
        }
        .userbox .list{
            height:38px;line-height: 38px;cursor:pointer;
            padding-left:10px;
        }
        .userbox .list:hover{
            background-color:#eeeeee;
        }
        .yname{
            font-size: 13px;
            color: #444;
        }
        input{
            border-radius:5px;
        }
        .layui-table-click {
            background-color: #ddf2e9 !important;
        }
        .xgrate{
            color: #fff;
            font-size: 15px;
            padding: 7px;
            height: 30px;
            line-height: 30px;
            background-color: #3475c3;
        }
        pre { padding: 5px; margin: 5px; }
        .string { color: #98c379; }
        .number { color: darkorange; }
        .boolean { color: blue; }
        .null { color: magenta; }
        .key { color: #d19a66; }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header">门店列表</div>
                            <div class="layui-card-body">
                                <div class="layui-btn-container" style="font-size:14px;">

                                    <!-- 省 -->
                                    <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:10px;display: inline-block;">
                                        <div class="layui-form-item">
                                            <div class="layui-input-block" style="margin-left:0;border-radius:5px">
                                                <text class="yname">选择省</text>
                                                <select name="province" lay-filter="filterProvince" id="province"></select>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- 市 -->
                                    <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:10px;display: inline-block;">
                                        <div class="layui-form-item">
                                            <div class="layui-input-block" style="margin-left:0;border-radius:5px">
                                                <text class="yname">选择市</text>
                                                <select name="city" lay-filter="filterCity" id="city">

                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- 区 -->
                                    <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:10px;display: inline-block;">
                                        <div class="layui-form-item">
                                            <div class="layui-input-block" style="margin-left:0;border-radius:5px">
                                                <text class="yname">选择区</text>
                                                <select name="area" lay-filter="filterArea" id="area"></select>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- 选择业务员 -->
                                    <!-- <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:10px;display: inline-block;">
                                    <div class="layui-form-item">
                                    <div class="layui-input-block" style="margin-left:0;border-radius:5px">
                                    <select name="agent" id="agent" lay-filter="agent">

                                    </select>
                                    </div>
                                    </div>
                                    </div> -->
                                    <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:10px;display: inline-block;">
                                        <div class="layui-form-item">
                                            <div class="layui-input-block" style="margin-left:0;border-radius:5px">
                                                <text class="yname">代理商名称</text>
                                                <input type="text" name="schoolname" lay-verify="schoolname" autocomplete="off" placeholder="请输入代理商名称"  class="layui-input transfer">
                                                <div class="userbox" style='display: none'></div>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- 审核状态 -->
                                    <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:10px;display: inline-block;">
                                        <div class="layui-form-item">
                                            <div class="layui-input-block" style="margin-left:0;border-radius:5px">
                                                <text class="yname">审核状态</text>
                                                <select name="status" id="status" lay-filter="status">
                                                    <option value="">全部</option>
                                                    <option value="1">审核成功</option>
                                                    <option value="2">未审核</option>
                                                    <option value="3">审核失败</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:10px;display: inline-block;">
                                        <div class="layui-form-item">
                                            <div class="layui-input-block" style="margin-left:0;border-radius:5px">
                                                <text class="yname">自主进件</text>
                                                <select name="is_incoming" id="is_incoming" lay-filter="is_incoming">
                                                    <option value="2">全部</option>
                                                    <option value="1">是</option>
                                                    <option value="0">否</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- 搜索 -->
                                    <!-- <div class="layui-form" lay-filter="component-form-group" style="width:100%;display: flex;"> -->
                                    <div class="layui-form" lay-filter="component-form-group" style="width:100%;">

                                        <!-- <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:10px;display: inline-block;"> -->
                                            <div class="layui-form-item layui-inline" style="width:190px;margin-right:10px;display: inline-block;">
                                                <div class="layui-input-block" style="margin-left:0;border-radius:5px">
                                                    <text class="yname">门店状态</text>
                                                    <select name="open" id="open" lay-filter="open">
                                                        <option value="0">未关闭</option>
                                                        <option value="2">全部</option>
                                                        <option value="1">已关闭</option>
                                                    </select>
                                                </div>
                                            </div>
                                        <!-- </div> -->

                                        <!-- <div class="layui-form" lay-filter="component-form-group" style="width:190px;margin-right:10px;display: inline-block;"> -->
                                            <div class="layui-form-item layui-inline" style="width:190px;margin-right:10px;display: inline-block;">
                                                <div class="layui-input-block" style="margin-left:0;border-radius:5px">
                                                    <text class="yname">是否删除</text>
                                                    <select name="del" id="del" lay-filter="del">
                                                        <option value="0">未删除</option>
                                                        <option value="2">全部</option>
                                                        <option value="1">已删除</option>
                                                    </select>
                                                </div>
                                            </div>
                                        <!-- </div> -->

                                        <!-- <div class="layui-form" style="display: inline-block;"> -->
                                            <div class="layui-form-item layui-inline">
                                                <div class="layui-input-inline">
                                                    <text class="yname">门店ID</text>
                                                    <input type="text" name="schoolname" placeholder="请输入门店名称或者门店ID" autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-form-item layui-inline">
                                                <div class="layui-input-inline">
                                                    <text class="yname">门店简称</text>
                                                    <input type="text" name="store_short_name" placeholder="请输入门店简称" autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-form-item layui-inline">
                                                <div class="layui-input-inline">
                                                    <text class="yname">搜索联系人</text>
                                                    <input type="text" name="search_phone" placeholder="请输入联系人手机号/名称" autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-form-item layui-inline">
                                                <div class="layui-input-inline">
                                                    <text class="yname">额度开关</text>
                                                    <select name="is_quota" id="is_quota" lay-filter="is_quota">
                                                        <option value="0">全部</option>
                                                        <option value="2">关</option>
                                                        <option value="1">开</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-form-item layui-inline">
                                                <button class="layui-btn layuiadmin-btn-list" lay-submit="" lay-filter="LAY-app-contlist-search" style="margin-top: 24px;border-radius:5px;margin-bottom: 0;height:36px;line-height: 36px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>


                                                <!-- <div class="layui-form-item" style="display: inline-block; margin-left: 30px;">
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            <text class="yname">搜索联系人</text>
                                                            <input type="text" name="search_phone" placeholder="请输入联系人手机号/名称" autocomplete="off" class="layui-input">
                                                        </div>
                                                    </div>

                                                    <div class="layui-inline">
                                                        <button class="layui-btn layuiadmin-btn-list" lay-submit="" lay-filter="LAY-app-contlist-phone" style="margin-top: 1.3rem;border-radius:5px;margin-bottom: 0;height:36px;line-height: 36px;">
                                                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                        </button>
                                                    </div>


                                                </div> -->
                                                <!-- 2025.7.30 门店导出屏蔽 -->
                                                <button class="layui-btn" style="margin-top: 26px;border-radius:5px;margin-bottom: 4px;height:36px;line-height: 36px;" lay-submit="" lay-filter="LAY-app-contlist-exprots">导出</button>
                                            </div>
                                        <!-- </div> -->

                                        

                                    </div>
                                    <div style="padding-bottom: 10px;">
                                        <!--<button class="layui-btn layuiadmin-btn-forum-list del" style="border-radius:5px;" data-type="batchdel">删除</button>-->
                                        <!--<button class="layui-btn layuiadmin-btn-forum-list recover" style="border-radius:5px;" data-type="recover">恢复</button>-->
                                        <button class="layui-btn layuiadmin-btn-forum-list close" style="border-radius:5px;" data-type="batchdelclose">关闭</button>
                                        <!--<button class="layui-btn layuiadmin-btn-forum-list open" style="border-radius:5px;" data-type="batchdelopen">开启</button>-->
                                        <button class="layui-btn layuiadmin-btn-forum-list" style="border-radius:5px;" data-type="transfer"><a class="addstoretransfer" lay-href="" style='color:#fff'>门店转移</a></button>
                                        <button class="layui-btn layuiadmin-btn-forum-list addstoers" style="border-radius:5px;padding:0;" data-type="addstore"><a class="addstore" lay-href="" style='color:#fff;padding:10px 20px;'>添加门店</a></button>
                                        <!--<button class="layui-btn layuiadmin-btn-forum-list recover" style="border-radius:5px;" data-type="batchdeltotaldel">清除商户</button>-->
                                    </div>
                                    <table class="layui-hide" id="test-table-page" lay-filter="test-table-page"></table>
                                    <!-- 判断状态 -->
                                    <script type="text/html" id="statusTap">
                                        @{{#  if(d.status == 1){ }}
                                        <span class="cur">@{{ d.status_desc }}</span>
                                        @{{#  } else { }}
                                        @{{ d.status_desc }}
                                        @{{#  } }}
                                    </script>
                                    <!-- 判断状态 -->
                                    <!-- 入驻地址 -->
                                    <script type="text/html" id="address">
                                        @{{ d.province_name }}@{{ d.city_name }}@{{ d.area_name }}@{{ d.store_address }}
                                    </script>
                                    <!-- 入驻地址 -->
                                    <script type="text/html" id="table-content-list" class="layui-btn-small">
                                        <a class="layui-btn layui-btn-normal layui-btn-xs see" lay-event="see" style="margin-right:3.5px;border-radius:3.5px">查看</a>
                                        <a class="layui-btn layui-btn-normal layui-btn-xs openbtn" lay-event="openbtn" style="margin-right:3.5px;border-radius:3.5px">门店管理</a>
                                        <a class="layui-btn layui-btn-normal layui-btn-xs passway" lay-event="passway" style="margin-right:3.5px;border-radius:3.5px;background-color: #FFB800;">通道管理</a>

                                        <a class="layui-btn  layui-btn-xs order" lay-event="order" lay-href="" style="margin-right:3.5px;border-radius:3.5px">交易流水</a>
                                        <a class="layui-btn  layui-btn-xs storecode" lay-event="storecode" style="margin-right:3.5px;border-radius:3.5px">门店收款码</a>
                                        <a class="layui-btn  layui-btn-xs storecodeHb" lay-event="storecodeHb" style="margin-right:3.5px;border-radius:3.5px">三码合一</a>
                                        <a class="layui-btn  layui-btn-xs merchcode" lay-event="merchcode" style="margin-right:3.5px;border-radius:3.5px">充值码</a>

                                        <a class="layui-btn layui-btn-xs certification" lay-event="certification" style="margin-right:3.5px;border-radius:3.5px">提交认证</a>
                                        <a class="layui-btn  layui-btn-xs shenhe" lay-event="shenhe" style="margin-right:3.5px;border-radius:3.5px">审核操作</a>
                                    </script>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="edit_rate" class="hide" style="display: none;background-color: #fff;">
        <div class="xgrate">门店收款码</div>
        <div class="layui-card-body" style="padding: 15px;">
            <div class="layui-form">
                <div class="layui-form-item">
                    <div style="display:flex;color: black;font-size: 16px;">
                        <div>门店名称：</div>
                        <div style="text-align: center;" class="storename"></div>
                        <a class="layui-btn layui-btn-normal layui-btn-xs mobanDown"  style="margin-left:10px;margin-right:3.5px;border-radius:3.5px">模板下载</a>
                    </div>
                    <div id="code"> </div>
                </div>
            </div>
        </div>
        <input type="hidden" class="store_short_name">
        <canvas id="poster-canvas" style="display:none;"></canvas>
    </div>

    <div id="edit_shenhe" class="hide" style="display: none;background-color: #fff;">
        <div class="xgrate">审核操作</div>
        <div class="layui-card-body" style="padding: 15px;">
            <div class="layui-form">
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">审核状态</label>
                    <div class="layui-input-block pass">
                        <input type="radio" name="sex" value="1" title="通过" checked="">
                        <input type="radio" name="sex" value="3" title="不通过">
                    </div>
                </div>
            </div>
            <div class="layui-form">
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">审核说明</label>
                    <div class="layui-input-block">
                        <textarea name="desc" placeholder="请输入内容" class="layui-textarea textarea"></textarea>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0;">
                        <button class="layui-btn closestore"style="border-radius:5px">确定</button>
                    </div>
                </div>
            </div>
            <input type="hidden" class="shenhe_store">
        </div>
    </div>

    <div id="edit_rata" class="hide" style="display: none;background-color: #fff;">
        <div class="xgrate">门店技术费率</div>
        <div class="layui-card-body" style="padding: 15px;">
            <div class="layui-form">
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">技术费率</label>
                    <div class="layui-input-block">
                        <input name="desc" placeholder="请输入技术费率" class="layui-input storerata">
                    </div>
                </div>
            </div>
            <div class="layui-form">
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">基本费率</label>
                    <div class="layui-input-block">
                        <input name="desc" placeholder="请输入基本费率" class="layui-input basicrata">
                    </div>
                </div>
            </div>
            <div class="layui-form">
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">代扣代理</label>
                    <div class="layui-input-block">
                        <input name="desc" placeholder="请输入渠道代理ID" class="layui-input withuser">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0;">
                        <button class="layui-btn ratastore"style="border-radius:5px">确定</button>
                    </div>
                </div>
            </div>
            <input type="hidden" class="rata_store">
        </div>
    </div>

    <div id="certification" class="hide" style="display: none;background-color: #fff;">
        <div class="xgrate">随行付微信认证</div>
        <div class="layui-card-body" style="padding: 15px;">
            {{--        <div class="layui-form">--}}
            {{--            <div class="layui-form-item" pane="">--}}
            {{--                <label class="layui-form-label">联系人姓名</label>--}}
            {{--                <div class="layui-input-block">--}}
            {{--                    <input name="desc" placeholder="请输入技术费率" class="layui-input contactName">--}}
            {{--                </div>--}}
            {{--            </div>--}}
            {{--        </div>--}}
            {{--        <div class="layui-form">--}}
            {{--            <div class="layui-form-item" pane="">--}}
            {{--                <label class="layui-form-label">联系人手机号</label>--}}
            {{--                <div class="layui-input-block">--}}
            {{--                    <input name="desc" placeholder="请输入基本费率" class="layui-input phoneNumber">--}}
            {{--                </div>--}}
            {{--            </div>--}}
            {{--        </div>--}}
            {{--        <div class="layui-form">--}}
            {{--            <div class="layui-form-item" pane="">--}}
            {{--                <label class="layui-form-label">联系人身份证号</label>--}}
            {{--                <div class="layui-input-block">--}}
            {{--                    <input name="desc" placeholder="请输入渠道代理ID" class="layui-input contactIdNo">--}}
            {{--                </div>--}}
            {{--            </div>--}}
            {{--        </div>--}}
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0;">
                        <button class="layui-btn certification commitApply"style="border-radius:5px">确定</button>
                        <button class="layui-btn certification queryApplyInfo"style="border-radius:5px; display: none">申请结果查询</button>
                        <div class="queryApplyInfo_img"> </div>
                        <button class="layui-btn certification backApplyBill"style="border-radius: 5px; display: none; margin-top: 5px">实名认证申请撤销</button>
                    </div>
                </div>
            </div>
            <input type="hidden" class="certification">
        </div>
    </div>

    <div id="open_button" class="hide" style="display: none;background-color: #fff;">
        <div class="layui-card-body" style="padding: 15px;">
            <div class="layui-form">
                <div class="layui-form-item box">
                    <div style="padding-bottom:14px;">
                        <label>门店名称:</label><span class="store_name_total"></span>
                    </div>
                    <a class="layui-btn layui-btn-normal layui-btn-xs pengyipeng" id="pengyipeng" style="margin-left:10px;border-radius:3px;">碰一碰设备管理</a>
                    <a class="layui-btn layui-btn-normal layui-btn-xs device" style="margin-left:10px;border-radius:3px;" lay-event="device" lay-href="{{url('/user/devicelist')}}">设备管理</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs edit" style="margin-left:10px;border-radius:3px;" lay-event="edit" lay-href="{{url('/user/editstore')}}">门店修改</a>
                    <!--<a class="layui-btn layui-btn-danger layui-btn-xs editdlb" style="margin-left:10px;border-radius:3px;" lay-event="editdlb" lay-href="{{url('/user/editdlbstore')}}">哆啦宝进件门店信息</a>-->
                    <a class="layui-btn  layui-btn-xs orderdown" style="margin-left:10px;border-radius:3px;">导出本月日统计</a>
                    {{--<a class="layui-btn layui-btn-danger layui-btn-xs editdlb" style="margin-left:10px;border-radius:3px;" lay-event="edithkrt" lay-href="{{url('/user/edithkrtstoreinfo')}}">海科融通补充进件信息</a>--}}
                    <a class="layui-btn  layui-btn-xs branchshop" style="margin-left:10px;border-radius:3px;" lay-event="branchshop" lay-href="">分店管理</a>
                    <a class="layui-btn  layui-btn-xs shouyin" style="margin-left:10px;border-radius:3px;" lay-event="shouyin">微收银插件</a>
                    {{--                <a class="layui-btn layui-btn-danger layui-btn-xs edit" style="margin-left:10px;border-radius:3px;" lay-event="edit" lay-href="{{url('/user/editstore')}}">重置密码</a>--}}
                    <a class="layui-btn  layui-btn-xs shouqianla" style="margin-left:10px;border-radius:3px;" lay-event="shouqianla">收钱啦插件</a>
                    <a class="layui-btn  layui-btn-xs yinghuochong" style="margin-left:10px;border-radius:3px;" lay-event="yinghuochong">萤火虫插件</a>
                    <!--<a class="layui-btn  layui-btn-xs merchantnumber" style="margin-left:10px;border-radius:3px;" lay-event="merchantnumber" lay-href="">新大陆D0管理</a>-->
                    <a class="layui-btn layui-btn-danger layui-btn-xs orderdownlast" style="margin-left:10px;border-radius:3px;">导出上月日统计</a>
                    {{--                <a class="layui-btn  layui-btn-xs merchantmanage" style="margin-left:10px;border-radius:3px;" lay-event="merchantmanage" lay-href="">快钱商户管理</a>--}}
                    {{--                <a class="layui-btn  layui-btn-xs fuyoumanage" style="margin-left:10px;border-radius:3px;" lay-event="fuyoumanage" lay-href="">富友商户管理</a>--}}
                    <a class="layui-btn  layui-btn-normal layui-btn-xs merchantlist" style="margin-left:10px;border-radius:3px;" lay-event="merchantlist" lay-href="">收银员管理</a>
                    <!--<a class="layui-btn  layui-btn-normal layui-btn-xs couponDetail" style="margin-left:10px;border-radius:3px;" lay-event="couponDetail" >单品管理</a>-->
                    <a class="layui-btn  layui-btn-normal layui-btn-xs rataDetail" style="margin-left:10px;border-radius:3px;" lay-event="rataDetail" >查看充值</a>
                    <a class="layui-btn  layui-btn-normal layui-btn-xs feeDetail" style="margin-left:10px;border-radius:3px;" lay-event="feeDetail" >查看扣费</a>

                    <a class="layui-btn  layui-btn-normal layui-btn-xs mechanism_merchant" style="margin-left:10px;border-radius:3px;" lay-event="mechanism_merchant" >关联机构</a>
                    <a class="layui-btn  layui-btn-normal layui-btn-xs nuonuo" style="margin-left:10px;border-radius:3px;" lay-event="nuonuo" >诺诺开票管理</a>
                    <a class="layui-btn  layui-btn-normal layui-btn-xs goods" style="margin-left:10px;border-radius:3px;" lay-event="goods" >单品管理</a>
                    <a class="layui-btn  layui-btn-normal layui-btn-xs refund" style="margin-left:10px;border-radius:3px;" lay-event="refund" >退款管理</a>
                    <a class="layui-btn  layui-btn-normal layui-btn-xs quota" style="margin-left:10px;border-radius:3px;" lay-event="quota" >额度管理</a>
                    <a class="layui-btn  layui-btn-normal layui-btn-xs bindWorker" style="margin-left:10px;border-radius:3px;" lay-event="bindWorker" >关联业务员</a>
                    <a class="layui-btn  layui-btn-normal layui-btn-xs beisaoTest" style="margin-left:10px;border-radius:3px;" lay-event="beisaoTest" >测试被扫支付</a>
                </div>
                {{--<div>--}}
                {{--<a class="layui-btn  layui-btn-xs daDaConfig" style="margin-left:10px;border-radius:3px;" lay-event="daDaConfig" lay-href="">达达配送</a>--}}
                {{--<a class="layui-btn  layui-btn-xs appletInformation" style="margin-left:10px;border-radius:3px;" lay-event="appletInformation" lay-href="">完善小程序信息</a>--}}
                {{--<a class="layui-btn  layui-btn-normal layui-btn-xs appletCode" style="margin-left:10px;border-radius:3px;" lay-event="appletCode" lay-href="">上传小程序代码</a>--}}
                {{--</div>--}}
            </div>
        </div>
    </div>
    <form  id="refund" style="display:none; margin-top: 40px;">

        <div class="layui-form-item">
            <label class="layui-form-label">隔日退开关</label>
            <div class="layui-input-block">
                <input type="radio" name="isBeforeRefund" id="isBeforeRefund" value="1" title="开" style="margin-top: 9px; width: 20px; height: 20px;">
                <span>开</span>
                <input type="radio" name="isBeforeRefund" id="isBeforeRefund" value="2" title="关" style="margin-left: 12px; margin-top: 9px; width: 20px; height: 20px;">
                <span>关</span>
            </div>
        </div>
    </form>
    <form  id="quota" style="display:none; margin-top: 40px;">

        <div class="layui-form-item">
            <label class="layui-form-label">额度开关</label>
            <div class="layui-input-block">
                <input type="radio" name="isQuota" id="isQuota" value="1" title="开" style="margin-top: 9px; width: 20px; height: 20px;">
                <span>开</span>
                <input type="radio" name="isQuota" id="isQuota" value="2" title="关" style="margin-left: 12px; margin-top: 9px; width: 20px; height: 20px;">
                <span>关</span>
            </div>
        </div>
    </form>
    <form  id="goods"  class="layui-form" style="display:none; margin-top: 40px;">
        <div class="layui-form-item">
            <label class="layui-form-label">商家费用</label>
            <div class="layui-input-block">
                <input type="text" name="goods_cost" required  lay-verify="required" placeholder="请输入费用" autocomplete="on" class="layui-input" id="cost" style="width:100px">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">代理费用</label>
            <div class="layui-input-block">
                <input type="text" name="agent_cost" required  lay-verify="required" placeholder="请输入费用" autocomplete="on" class="layui-input" id="agent_cost" style="width:100px">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单品</label>
            <div class="layui-input-block">
                <input type="radio" name="isGoods" id="isGoods" lay-filter="isGoodsFilter" value="1" title="开" style="margin-top: 9px; width: 20px; height: 20px;">
                <input type="radio" name="isGoods" id="isGoods" lay-filter="isGoodsFilter" value="2" title="关" style="margin-left: 12px; margin-top: 9px; width: 20px; height: 20px;">
            </div>
        </div>
        <div class="layui-form-item saoSelBtns">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <input type="checkbox" name="isSaoBtn" title="扫一扫" lay-skin="primary" style="margin-top: 9px; width: 20px; height: 20px;">
                <input type="checkbox" name="isSelBtn" title="选一选" lay-skin="primary" style="margin-left: 12px; margin-top: 9px; width: 20px; height: 20px;">
            </div>
        </div>
    </form>
    <!-- 门店关联业务员 -->
    <div id="bindWorkerModal" class="hide" style="display: none; background-color: #fff;padding: 30px 15px;height:400px">
        <div class="layui-form" lay-filter="component-form-group" style="width:500px;margin-right:0;display: inline-block;">
            <div class="layui-form-item" style="display:flex">
                <div class="layui-input-block layui-inline" style="margin-left:5px;border-radius:5px;width:350px">
                    <text class="yname">选择业务员</text>
                    <select name="workerSel" class="workerSel" lay-filter="workerSel" lay-search>
                        <!-- <option value="">请选择</option> -->
                    </select> 
                </div>
                <div class="layui-inline">
                    <div class="layui-input-block" style="margin-left:5px;border-radius:5px">
                        <a class="layui-btn layui-btn-primary bindWorkerConfirm" style="background-color:#3475c3;border-radius: 5px;border:none;color:#fff;margin-top:20px;display: block;width: 122px;">确定</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 门店微信支付宝认证码 -->
    <div id="wxAliRzcode" class="hide" style="display: none; background-color: #fff;padding: 30px 15px;height:750px">
        <div style="display:flex;color: black;font-size: 16px;">
            <div>门店名称：</div>
            <div style="text-align: center;" class="storename"></div>
        </div>
        <div style="display:flex;color: black;font-size: 16px;margin-top: 4px;">
            <div>门店简称：</div>
            <div style="text-align: center;" class="storeshortname"></div>
        </div>
        <div style="display:flex;height:60px;margin-top: 30px;">
            <!-- <div style="width:33%;text-align: center;"> <h2>门店收款码</h2></div> -->
            <div style="width:100%">
                <div style="text-align:center;display:flex;justify-content: center;align-items: center;">
                    <h2>随行付认证码</h2>
                    <a class="layui-btn  layui-btn-normal applyRzBtn" style="margin-left:15px;border-radius:3px;display:none">一键认证</a>
                    <a class="layui-btn layui-btn-danger layui-btn-normal applyCxBtn" style="margin-left:10px;border-radius:3px;display:none">一键撤销</a>
                </div>
            </div>
        </div>
        <div style="display: flex">
            <!-- <div style="width:33%;display: flex;align-items: center;min-height: 500px">
                <div style="padding:0 4px;text-align:center;">
                    <div>
                        <div id="qrcodeShow" style="display:none">
                            <div id="code"> </div>
                            <canvas id="qrcode-canvas"></canvas>
                        </div>
                        <div id="qrcodeImg" style="display:none"><img id="qrcodeImgUrl" style="width:100%;height:100%;box-shadow: 0 4px 8px 0 #0000001a;"></div>
                    </div>
                </div>
                <div style="wdith:2px;height: 350px;border-right: 2px #e2e2e2 dashed;"></div>
            </div> -->
            <div style="width:100%;display:flex;align-items: center;min-height: 500px">
                <div style="padding:0 8px;text-align:center;width: 50%;">
                    <div id="wxcodeShow" style="display:none">
                        <canvas id="wxcode-canvas"></canvas>
                    </div>
                    <div id="wxcodeImg" style="display:none"><img id="wxcodeImgUrl" style="width:100%;height:100%;box-shadow: 0 4px 8px 0 #0000001a;"></div>
                    <div class="wxResult" style="display:none;font-size: 14px;padding:0 20px;line-height: 22px;"><text class="bohuiResult" style="color:red"></text></div>
                    <div class="wxNoOPenResult" style="display:none;font-size: 14px;padding:0 20px;line-height: 22px;"><text class="wxNoOpenText" style="color:red"></text></div>
                </div>
                <div style="padding:0 8px;text-align:center;width: 50%;" >
                    <div id="alipaycodeShow">
                        <canvas id="alipaycode-canvas" style="display:none;"></canvas>
                    </div>
                    <div id="alipaycodeImg" style="display:none;"><img id="alipaycodeImgUrl" style="width:100%;height:100%;box-shadow: 0 4px 8px 0 #0000001a;"></div>
                    <div class="alipayResult" style="display:none;font-size: 14px;padding:0 20px;line-height: 22px;"><text class="alipaybohuiResult" style="color:red"></text></div>
                    <div class="alipayNoOPenResult" style="display:none;font-size: 14px;padding:0 20px;line-height: 22px;"><text class="alipayNoOpenText" style="color:red"></text></div>
                </div>
            </div>
        </div>
        <div style="display: flex;margin-top:30px;">
            <!-- <div style="width:33%;text-align:center">
                <a class="layui-btn  layui-btn-normal downImg" style="border-radius:3px;display:none">下载门店收款码</a>
            </div> -->
            <div style="width:50%;text-align:center">
                <a class="layui-btn  layui-btn-normal downWxImg" style="border-radius:3px;display:none">下载微信认证码</a>
            </div>
            <div style="width:50%;text-align:center">
                <a class="layui-btn  layui-btn-normal downAlipayImg" style="border-radius:3px;display:none">下载支付宝认证码</a>
            </div>
        </div>
        <input type="hidden" class="store_short_name">
    </div>
    <!-- 测试被扫 -->
    <div id="beisaoTestModal" class="hide" style="display: none; background-color: #fff;padding: 30px 15px;min-height:400px;">
        <div style="display:flex;">
            <div style="width:100%;display:flex;">
                <div style="width:100%;padding:0 8px;">
                    <div class="layui-tab">
                        <ul class="layui-tab-title">
                            <li class="layui-this">支付</li>
                            <li>查询</li>
                            <li>退款</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form">
                                    <div class="layui-form-item" pane="">
                                        <label class="layui-form-label">付款码</label>
                                        <div class="layui-input-block">
                                            <input name="desc" placeholder="请输入付款码" class="layui-input code">
                                        </div>
                                    </div>
                                    <div class="layui-form-item" pane="">
                                        <label class="layui-form-label">付款金额</label>
                                        <div class="layui-input-block">
                                            <input name="desc" placeholder="请输入付款金额" class="layui-input total_amount">
                                        </div>
                                    </div>
                                    <div class="layui-form-item" pane="">
                                        <div class="layui-input-block">
                                            <button class="layui-btn payConfirm"style="border-radius:5px">提交</button>
                                        </div>
                                    </div>
                                    <div class="returnInfoShow" style="padding:20px 10px;background-color: #384548;color: #fff;margin-top:40px;display:none;border-radius:8px">
                                        <div>
                                            <pre id='returnInfo' style="white-space: pre-wrap;"></pre>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item">
                                <div class="layui-form">
                                    <div class="layui-form-item" pane="">
                                        <label class="layui-form-label">订单号</label>
                                        <div class="layui-input-block">
                                            <input name="desc" placeholder="请输入订单号" class="layui-input out_trade_no_select">
                                        </div>
                                    </div>
                                    <div class="layui-form-item" pane="">
                                        <div class="layui-input-block">
                                            <button class="layui-btn selectPayConfirm"style="border-radius:5px">提交</button>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item returnInfoSelShow" style="padding:20px 0;background-color: #384548;color: #fff;margin-top:40px;border-radius:8px;display:none;">
                                    <div class="">
                                        <pre id='returnInfo_select' style="white-space: pre-wrap;"></pre>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item">
                                <div class="layui-form">
                                    <div class="layui-form-item" pane="">
                                        <label class="layui-form-label">退款金额</label>
                                        <div class="layui-input-block">
                                            <input name="desc" placeholder="请输入退款金额" class="layui-input refund_amount">
                                        </div>
                                    </div>
                                    <div class="layui-form-item" pane="">
                                        <label class="layui-form-label">订单号</label>
                                        <div class="layui-input-block">
                                            <input name="desc" placeholder="请输入订单号" class="layui-input out_trade_no_refund">
                                        </div>
                                    </div>
                                    <div class="layui-form-item" pane="">
                                        <label class="layui-form-label">退款单号</label>
                                        <div class="layui-input-block">
                                            <input name="desc" placeholder="请输入退款单号" class="layui-input refund_no">
                                        </div>
                                    </div>
                                    <div class="layui-form-item" pane="">
                                        <div class="layui-input-block">
                                            <button class="layui-btn refundConfirm"style="border-radius:5px">提交</button>
                                        </div>
                                    </div>
                                    <div class="returnInfoRefShow" style="padding:20px 0;background-color: #384548;color: #fff;margin-top:40px;border-radius:8px;display:none;">
                                        <div>
                                            <pre id='returnInfo_refund' style="white-space: pre-wrap;"></pre>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" class="goods_cost">
    <input type="hidden" class="agent_cost">
    <input type="hidden" class="is_goods">
    <input type="hidden" class="is_before_refund">
    <input type="hidden" class="is_quota">
    <input type="hidden" class="js_store_id">
    <input type="hidden" class="js_id">
    <input type="hidden" class="js_store_name">

    <input type="hidden" class="user_id">
    <input type="hidden" class="status">

    <input type="hidden" class="provincecode" value="">
    <input type="hidden" class="provincename" value="">
    <input type="hidden" class="citycode" value="">
    <input type="hidden" class="cityname" value="">
    <input type="hidden" class="areacode" value="">
    <input type="hidden" class="areaname" value="">

    <input type="hidden" class="open_id" value="0">
    <input type="hidden" class="del_id" value="0">
    <input type="hidden" class="isSaoBtn" value="">
    <input type="hidden" class="isSelBtn" value="">
    <input type="hidden" class="js_store_user_id" value="">
    <input type="hidden" class="merchant_id">

    <script src="{{asset('/layuiadmin/layui/layui.js')}}"></script>
    <script src="{{asset('/layuiadmin/layui/jquery-2.1.4.js')}}"></script>
    <script src="{{asset('/layuiadmin/layui/jquery.qrcode.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('/school/js/md5.js')}}"></script>
    <script>
        var token = localStorage.getItem("Usertoken");
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index','form','table'], function(){
            var $ = layui.$
                ,admin = layui.admin
                ,form = layui.form
                ,table = layui.table
                ,element = layui.element; 

            // 未登录,跳转登录页面
            $(document).ready(function(){
                if(token==null){
                    window.location.href="{{url('/user/login')}}";
                }
                $('.recover').hide();
                $('.open').hide();
            });

            $(".transfer").bind("input propertychange", function (event) {
                //  console.log($(this).val())
                user_name = $(this).val();
                if (user_name.length == 0) {
                    $('.userbox').html('');
                    $('.userbox').hide();
                } else {
                    $.post("{{url('/api/user/get_sub_users')}}",
                        {
                            token: token,
                            user_name: user_name,
                            self: '1'
                        }, function (res) {
                            //   console.log(res);
                            var html = "";
//                console.log(res.t);
                            if (res.t == 0) {
                                $('.userbox').html('');
                                $('.userbox').hide();
                            } else {
                                for (var i = 0; i < res.data.length; i++) {
                                    html += '<div class="list" data=' + res.data[i].id + '>' + res.data[i].name + '-' + res.data[i].level_name + '</div>'
                                }
                                $(".userbox").show();
                                $('.userbox').html('');
                                $('.userbox').append(html);
                            }
                        }, "json");
                }
            });

            $(".orderdown").on("click", function (event) {
                var store_id = $('.js_store_id').val();
                // console.log(token);return;
                window.location.href="{{url('/api/export/UserOrderExcelDownLoad')}}"+'?token='+token+'&store_id='+store_id+'&month=1';
            });

            $(".orderdownlast").on("click", function (event) {
                var store_id = $('.js_store_id').val();
                // console.log(token);return;
                window.location.href="{{url('/api/export/UserOrderExcelDownLoad')}}"+'?token='+token+'&store_id='+store_id+'&month=2';
            });

            // 添加机构号
            // $(".mechanism_merchant").on("click", function (event) {
            //     var store_id = $('.js_store_id').val();
            //     // console.log(token);return;
            //     window.location.href="{{url('/api/glow/mechanism_merchant_add')}}"+'?token='+token+'&store_id='+store_id+'&month=2';
            // });

            $(".userbox").on("click",".list",function(){
                $('.transfer').val($(this).html());
                $('.js_user_id').val($(this).attr('data'));
                $('.userbox').hide();

                table.reload('test-table-page', {
                    where: {
                        user_id:$(this).attr('data')
                    }
                    ,page: {
                        curr: 1
                    }
                });
            });

            // 选择业务员
            $.ajax({
                url : "{{url('/api/user/get_sub_users')}}",
                data : {token:token},
                type : 'post',
                success : function(data) {
                    //console.log(data);
                    var optionStr = "";
                    if(data.data && data.data.length>0){
                    for(var i=0;i<data.data.length;i++){
                        if(i == 0){
                            optionStr += "<option selected value='" + data.data[i].id + "'>" + data.data[i].name + "</option>";
                        }else{
                            optionStr += "<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>";
                        }
                    }
                    }
                    $("#agent").append('<option value="">选择业务员</option>'+optionStr);
                    layui.form.render('select');
                },
                error : function(data) {
                    alert('查找板块报错');
                }
            });

            // 地区选择
            $.ajax({
                url : "{{url('/api/basequery/city')}}",
                data : {area_code:'1'},
                type : 'get',
                success : function(data) {
                    //console.log(data);
                    var optionStr = "";
                    for(var i=0; i<data.data.length; i++){
                        optionStr += "<option value='" + data.data[i].area_code + "'>" + data.data[i].area_name + "</option>";
                    }
                    $("#province").append('<option value="">请选择省</option>'+optionStr);
                    layui.form.render('select');
                },
                error : function(data) {
                    alert('查找板块报错');
                }
            });

            // 渲染表格
            table.render({
                elem: '#test-table-page'
                ,url: "{{url('/api/user/store_pc_lists')}}"
                ,method: 'post'
                ,where:{
                    token:token,
                    is_close: $('.open_id').val(),
                    is_delete: $('.del_id').val()
                }
                ,request:{
                    pageName: 'p',
                    limitName: 'l'
                }
                ,page: true
                // ,cellMinWidth: 150
                ,cols: [[
                    {type:'checkbox', fixed: 'left'}
//            ,{field:"",  title: '门店状态',width:116}
                    ,{field:'created_at',  title: '入驻时间',width:116}
                    ,{field:'store_id', title: '门店id',width:120}
                    ,{field:'store_name', title: '门店名称',width:168}
                    ,{field:'store_short_name', title: '门店简称',width:168}
                    ,{field:'branch', title: '分店',width:80}
                    ,{field:'store_type_name', title: '商户类型',width:100}
                    ,{field:'user_name', title: '归属'}
                    ,{field:'people',  title: '联系人',width:100}
                    ,{field:'people_phone',  title: '联系电话',width:144}
                    ,{field:'stu_class_name',  title: '门店地址',templet:'#address'}
                    ,{field:'pay_status_desc', title: '状态',templet:'#statusTap',width:88}
                    ,{field:'store_money', title: '预充值余额',templet:'#ratafee',width:88}
                    ,{field:'goods_cost_balance', title: '单品余额',templet:'#ratafee',width:88}
                    ,{field:'p_store_id', title: '总店id',width:120,templet:function(info){
                        return (info.p_info && info.p_info.store_id) || ''
                    }}
                    ,{field:'p_store_name', title: '总店名称',width:168,templet:function(info){
                        return (info.p_info && info.p_info.store_name) || ''
                    }}
                    ,{field:'is_incoming', title: '自主进件',width:100,templet:function(info){
                        return info.is_incoming == 1 ? '是' : (info.is_incoming == 2 ? '全部' : '否')
                    }}
                    ,{width: 600, align:'center', fixed: 'right', toolbar: '#table-content-list',title: '操作'}
                ]]
                ,response: {
                    statusName: 'status' //数据状态的字段名称，默认：code
                    ,statusCode: 1 //成功的状态码，默认：0
                    ,msgName: 'message' //状态信息的字段名称，默认：msg
                    ,countName: 't' //数据总数的字段名称，默认：count
                    ,dataName: 'data' //数据列表的字段名称，默认：data
                }
                ,done: function(res, curr, count){
                    //console.log(res);
                    $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'black','background':'linear-gradient(#f2f2f2,#cfcfcf)'}); //进行表头样式设置
                }
            });

            table.on('tool(test-table-page)', function(obj){
                var e = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var tr = obj.tr; //获得当前行 tr 的DOM对象
                // localStorage.setItem('s_store_id', e.store_id);
                if(obj.tr.hasClass('layui-table-click')){
                    obj.tr.removeClass('layui-table-click');
                } else {
                    obj.tr.addClass('layui-table-click');
                }

                var index = obj.tr.data('index');
                var tableData = table.cache.menu;//menu是表格id
                var trHasClass = obj.tr.hasClass('layui-table-click');

                layui.each(tableData,function(i,item){
                    if(trHasClass == true){
                        if(index == i){
                            item.LAY_CHECKED = true;
                        }
                    }else{
                        if(index == i){
                            item.LAY_CHECKED = false;
                        }
                    }
                });

                if(layEvent === 'see'){ //审核
                    layer.open({
                        type: 2,
                        title: '详细',
                        shade: false,
                        maxmin: true,
                        area: ['90%', '85%'],
                        content: "{{url('/user/seestore?')}}"+e.store_id
                    });
                }
                else if(layEvent === 'openbtn'){
                    localStorage.setItem('store_store_id', e.store_id);
                    localStorage.setItem('store_store_name', e.store_name);
                    console.log(e)
                    $('.is_goods').val(e.is_goods);
                    $('.is_before_refund').val(e.is_before_refund);
                    $('.is_quota').val(e.is_quota);
                    $('.goods_cost').val(e.goods_cost);
                    $('.agent_cost').val(e.agent_cost);
                    $('.js_store_id').val(e.store_id);
                    $('.js_id').val(e.id);
                    $('.js_store_name').val(e.store_name);
                    $('.store_name_total').html(e.store_name);
                    $('.isSaoBtn').val(e.store_btn ? e.store_btn.btn2 : '')
                    $('.isSelBtn').val(e.store_btn ? e.store_btn.btn1 : '')
                    $('.js_store_user_id').val(e.user_id);
                    $('.merchant_id').val(e.merchant_id);

                    layer.open({
                        type: 1,
                        title: false,
                        closeBtn: 0,
                        area: '516px',
                        skin: 'layui-layer-nobg', //没有背景色
                        shadeClose: true,
                        content: $('#open_button')
                    });
                }
                else if(layEvent === 'edit'){
                    // $('.edit').attr('lay-href',"{{url('/user/modifystore?store_id=')}}"+e.store_id);
                    localStorage.setItem('store_store_id', e.store_id);
                    localStorage.setItem('store_province_code', e.province_code);
                    localStorage.setItem('store_city_code', e.city_code);
                    localStorage.setItem('store_area_code', e.area_code);
                }
                else if(layEvent === 'device'){
                    localStorage.setItem('store_store_id', e.store_id);
                    localStorage.setItem('store_store_name', e.store_name);
                }
                else if(layEvent === 'order'){
                    $('.order').attr('lay-href',"{{url('/user/tradelistNew?')}}"+e.store_id);
                    localStorage.setItem('s_storename', e.store_name);
                }
                else if(layEvent === 'passway'){
                    localStorage.setItem('store_store_name', e.store_name);
                    $('.passway').attr('lay-href',"{{url('/user/passway?')}}"+e.store_id);
                }
                else if(layEvent === 'branchshop'){
                    $('.branchshop').attr('lay-href',"{{url('/user/branchshop?id=')}}"+e.id+"&store_name="+e.store_name);
                }
                else if(layEvent === 'storecode'){
                    $('.storename').html(e.store_name);
                    $('#edit_rate .store_short_name').val(e.store_short_name)
                    $.post("{{url('/api/user/store_pay_qr')}}",
                        {
                            token:token
                            ,store_id:e.store_id
                        },
                        function(res){
                            if(res.status==1){
                                $('#code').html('');
                                $('#code').qrcode(res.data.store_pay_qr);
                                layer.open({
                                    type: 1,
                                    title: false,
                                    closeBtn: 0,
                                    area: '516px',
                                    skin: 'layui-layer-nobg', //没有背景色
                                    shadeClose: true,
                                    content: $('#edit_rate')
                                });
                            }else if(res.status==2){
                                layer.msg(res.message, {
                                    offset: '50px'
                                    ,icon: 2
                                    ,time: 3000
                                });
                            }
                        },"json");
                    
                }else if(layEvent === 'storecodeHb'){ //三码合一
                    $('.storename').html(e.store_name);
                    $('.storeshortname').html(e.store_short_name);
                    $('#wxAliRzcode .store_short_name').val(e.store_short_name)
                    $('.js_store_id').val(e.store_id);
                    layer.open({
                        type: 1,
                        title: '三码合一',
                        closeBtn: 1,
                        area: '750px',
                        skin: 'layui-layer-nobg', //没有背景色
                        shadeClose: true,
                        content: $('#wxAliRzcode'),
                        end:function(){
                            wxaliCodeReset()
                        }
                    });
                    getThreeCode()
                }
                else if(layEvent === 'merchcode'){
                    $('.storename').html(e.store_name);
                    $.post("{{url('/api/user/store_pay_qr1')}}",
                        {
                            token:token
                            ,store_id:e.store_id
                        },
                        function(res){
                            if(res.status==1){
                                $('#code').html('');
                                $('#code').qrcode(res.data.store_pay_qr);
                                layer.open({
                                    type: 1,
                                    title: false,
                                    closeBtn: 0,
                                    area: '516px',
                                    skin: 'layui-layer-nobg', //没有背景色
                                    shadeClose: true,
                                    content: $('#edit_rate')
                                });
                            }else if(res.status==2){
                                layer.msg(res.message, {
                                    offset: '50px'
                                    ,icon: 2
                                    ,time: 3000
                                });
                            }
                        },"json");
                }
                else if(layEvent === 'shouyin'){
                    $('.shouyin').attr('lay-href',"{{url('/user/shouyin?store_id=')}}"+e.store_id+"&store_name="+e.store_name);
                }
                else if(layEvent === 'shouqianla'){
                    $('.shouqianla').attr('lay-href',"{{url('/user/shouqianla?store_id=')}}"+e.store_id+"&store_name="+e.store_name);
                }
                else if(layEvent === 'yinghuochong'){
                    $('.yinghuochong').attr('lay-href',"{{url('/user/yinghuochong?store_id=')}}"+e.store_id+"&store_name="+e.store_name);
                }
                else if(layEvent === 'shenhe'){
                    $('.shenhe_store').val(e.store_id);
                    layer.open({
                        type: 1,
                        title: false,
                        closeBtn: 0,
                        area: '516px',
                        skin: 'layui-layer-nobg', //没有背景色
                        shadeClose: true,
                        content: $('#edit_shenhe')
                    });
                }
                else if(layEvent === 'rata'){
                    $('.rata_store').val(e.store_id);
                    $('.storerata').val(e.rata_store);
                    $('.basicrata').val(e.basic_rata);
                    $('.withuser').val(e.with_user);
                    layer.open({
                        type: 1,
                        title: false,
                        closeBtn: 0,
                        area: '516px',
                        skin: 'layui-layer-nobg', //没有背景色
                        shadeClose: true,
                        content: $('#edit_rata')
                    });
                }
                else if(layEvent === 'editdlb'){
                    localStorage.setItem('store_store_id', e.store_id);
                    localStorage.setItem('store_province_code', e.province_code);
                    localStorage.setItem('store_city_code', e.city_code);
                    localStorage.setItem('store_area_code', e.area_code);
                }
                else if(layEvent === 'certification'){
                    $('.rata_store').val(e.store_id);
                    $('.contactName').val(e.contactName);
                    $('.phoneNumber').val(e.phoneNumber);
                    $('.contactIdNo').val(e.contactIdNo);
                    layer.open({
                        type: 1,
                        title: false,
                        closeBtn: 0,
                        area: '516px',
                        skin: 'layui-layer-nobg', //没有背景色
                        shadeClose: true,
                        content: $('#certification')
                    });
                }
            });

            // 新添加的弹框按钮2019.1.14****
            $('.passway').click(function(){
                $(this).attr('lay-href',"{{url('/user/passway?')}}"+$('.js_store_id').val());
            });
            $('.branchshop').click(function(){
                $(this).attr('lay-href',"{{url('/user/branchshop?id=')}}"+$('.js_id').val()+"&store_name="+$('.js_store_name').val());
            });
            $('.shouyin').click(function(){
                $('.shouyin').attr('lay-href',"{{url('/user/shouyin?store_id=')}}"+$('.js_store_id').val()+"&store_name="+$('.js_store_name').val());
            });
            $('.shouqianla').click(function(){
                $('.shouqianla').attr('lay-href',"{{url('/user/shouqianla?store_id=')}}"+$('.js_store_id').val()+"&store_name="+$('.js_store_name').val());
            });
            $('.yinghuochong').click(function(){
                $('.yinghuochong').attr('lay-href',"{{url('/user/yinghuochong?store_id=')}}"+$('.js_store_id').val()+"&store_name="+$('.js_store_name').val());
            });
            $('.merchantnumber').click(function(){
                $(this).attr('lay-href',"{{url('/user/merchantnumber?')}}"+$('.js_store_id').val());
            });
            $('.merchantmanage').click(function(){
                $(this).attr('lay-href',"{{url('/user/merchantmanage?')}}"+$('.js_store_id').val());
            });
            $('.fuyoumanage').click(function(){
                $(this).attr('lay-href',"{{url('/user/fuyoumanage?')}}"+$('.js_store_id').val());
            });
            $('.merchantlist').click(function(){
                $(this).attr('lay-href',"{{url('/user/merchantlist?')}}"+$('.js_store_id').val());
            });
            $('.couponDetail').click(function(){
                $(this).attr('lay-href',"{{url('/user/couponDetail?')}}"+$('.js_store_id').val());
            });
            $('.rataDetail').click(function(){
                $(this).attr('lay-href',"{{url('/user/rataDetail?')}}"+$('.js_store_id').val());
            });
            $('.feeDetail').click(function(){
                $(this).attr('lay-href',"{{url('/user/feeDetail?')}}"+$('.js_store_id').val());
            });
            $('.daDaConfig').click(function(){
                $(this).attr('lay-href',"{{url('/user/dadaconfig?')}}"+$('.js_store_id').val());
            });
            $('.appletInformation').click(function(){
                $(this).attr('lay-href',"{{url('/user/appletInformation?')}}"+$('.js_store_id').val());
            });
            $('.appletCode').click(function(){
                $(this).attr('lay-href',"{{url('/user/appletCode?')}}"+$('.js_store_id').val());
            });
            $('.nuonuo').click(function(){
                $(this).attr('lay-href',"{{url('/user/nuonuo_list?')}}"+$('.js_store_id').val());
            });
            $('.refund').click(function(){

                if ($('.is_before_refund').val() == 1) {
                    console.log(666)
                    //$("#isGoods").prop("checked", true)
                    $('input[name="isBeforeRefund"][value="1"]').prop('checked', true);
                } else {
                    console.log(777)
                    //$("#isGoods").prop("checked", false)
                    $('input[name="isBeforeRefund"][value="2"]').prop('checked', true);
                }

                var token = localStorage.getItem("Usertoken");
                var store_id = $('.js_store_id').val();
                layer.open({
                    type:1,
                    area:['300px','350px'],
                    title: '退款管理'
                    ,content: $("#refund"),
                    shade: 0,
                    btn: ['提交']
                    ,btn1: function(index, layero){
                        $.ajax({
                            url : "{{url('/api/user/up_store_refund')}}",
                            data : {
                                is_before_refund:$("input[name='isBeforeRefund']:checked").val(),
                                token:token,
                                store_id:store_id
                            },
                            type : 'get',
                            success : function(data) {
                                if (data.status == 1) {
                                    layer.alert('更新成功')
                                    layer.closeAll();
                                    //执行重载
                                    table.reload('test-table-page', {
                                        where: {
                                            province_code:$('.provincecode').val(),
                                            city_code:$('.citycode').val(),
                                            area_code:$('.areacode').val()
                                        }
                                        ,page: {
                                            curr: 1
                                        }
                                    });
                                } else {
                                    layer.alert(data.message)
                                }
                            },
                            error : function(data) {
                                layer.alert('网络异常')
                            }
                        });
                    },
                    btn2: function(index, layero){

                    },
                    cancel: function(layero,index){
                        layer.closeAll();
                    }

                });
            });

            $('.quota').click(function(){

                if ($('.is_quota').val() == 1) {
                    console.log(666)
                    //$("#isGoods").prop("checked", true)
                    $('input[name="isQuota"][value="1"]').prop('checked', true);
                } else {
                    console.log(777)
                    //$("#isGoods").prop("checked", false)
                    $('input[name="isQuota"][value="2"]').prop('checked', true);
                }

                var token = localStorage.getItem("Usertoken");
                var store_id = $('.js_store_id').val();
                layer.open({
                    type:1,
                    area:['300px','350px'],
                    title: '额度管理'
                    ,content: $("#quota"),
                    shade: 0,
                    btn: ['提交']
                    ,btn1: function(index, layero){
                        $.ajax({
                            url : "{{url('/api/user/up_store_quota')}}",
                            data : {
                                is_quota:$("input[name='isQuota']:checked").val(),
                                token:token,
                                store_id:store_id
                            },
                            type : 'get',
                            success : function(data) {
                                if (data.status == 1) {
                                    layer.alert('更新成功')
                                    layer.closeAll();
                                    //执行重载
                                    table.reload('test-table-page', {
                                        where: {
                                            province_code:$('.provincecode').val(),
                                            city_code:$('.citycode').val(),
                                            area_code:$('.areacode').val()
                                        }
                                        ,page: {
                                            curr: 1
                                        }
                                    });
                                } else {
                                    layer.alert(data.message)
                                }
                            },
                            error : function(data) {
                                layer.alert('网络异常')
                            }
                        });
                    },
                    btn2: function(index, layero){

                    },
                    cancel: function(layero,index){
                        layer.closeAll();
                    }

                });
            });

            form.on('radio(isGoodsFilter)', function(data){
                console.log(data.value); //被点击的radio的value值
                if(data.value == 1){
                    $('.saoSelBtns').show()
                }else{
                    $('.saoSelBtns').hide()
                }
            })
            $('.goods').click(function(){

                if ($('.is_goods').val() == 1) {
                    console.log(666)
                    //$("#isGoods").prop("checked", true)
                    $('input[name="isGoods"][value="1"]').prop('checked', true);
                    console.log($('.isSaoBtn').val())
                    console.log($('.isSaoBtn').val()!=='' && $('.isSaoBtn').val() == 0)
                    if($('.isSaoBtn').val()!=='' && $('.isSaoBtn').val() == 0){
                        $('input[name="isSaoBtn"]').prop('checked',true)
                    }else{
                        $('input[name="isSaoBtn"]').prop('checked',false)
                    }
                    if($('.isSelBtn').val()!=='' && $('.isSelBtn').val() == 0){
                        $('input[name="isSelBtn"]').prop('checked',true)
                    }else{
                        $('input[name="isSelBtn"]').prop('checked',false)
                    }
                    $('.saoSelBtns').show()
                } else {
                    console.log(777)
                    //$("#isGoods").prop("checked", false)
                    $('input[name="isGoods"][value="2"]').prop('checked', true);
                    $('.saoSelBtns').hide()
                }
                form.render()
                $('input[name="goods_cost"]').val($('.goods_cost').val());
                $('input[name="agent_cost"]').val($('.agent_cost').val());
                var token = localStorage.getItem("Usertoken");
                var store_id = $('.js_store_id').val();
                layer.open({
                    type:1,
                    area:['300px','350px'],
                    title: '单品管理'
                    ,content: $("#goods"),
                    shade: 0,
                    btn: ['提交']
                    ,btn1: function(index, layero){
                        var isSaoChecked = $('input[name="isSaoBtn"]').prop('checked');
                        var isSelChecked = $('input[name="isSelBtn"]').prop('checked');
                        console.log(isSaoChecked,isSelChecked,'111')
                        let params = {
                            is_goods:$("input[name='isGoods']:checked").val(),
                            goods_cost:$('input[name="goods_cost"]').val(),
                            agent_cost:$('input[name="agent_cost"]').val(),
                            token:token,
                            store_id:store_id,
                        }
                        if($("input[name='isGoods']:checked").val() == 1){
                            params['btn1'] = isSelChecked ? 0 : 1
                            params['btn2'] = isSaoChecked ? 0 : 1
                        }
                        $.ajax({
                            url : "{{url('/api/user/up_store_goods')}}",
                            data : params,
                            type : 'get',
                            success : function(data) {
                                if (data.status == 1) {
                                    layer.alert('更新成功')
                                    layer.closeAll();
                                    //执行重载
                                    table.reload('test-table-page', {
                                        where: {
                                            province_code:$('.provincecode').val(),
                                            city_code:$('.citycode').val(),
                                            area_code:$('.areacode').val()
                                        }
                                        ,page: {
                                            curr: 1
                                        }
                                    });
                                } else {
                                    layer.alert(data.message)
                                }
                            },
                            error : function(data) {
                                layer.alert('网络异常')
                            }
                        });
                    },
                    btn2: function(index, layero){

                    },
                    cancel: function(layero,index){
                        layer.closeAll();
                    }

                });
            });
            // 添加机构号
            $('.mechanism_merchant').click(function(){
                // console.log(2)
                $(this).attr('lay-href',"{{url('/user/mechanism_merchant_add?')}}"+$('.js_store_id').val());
            });
            // *********end

            // 省市区start-------------------------------
            form.on('select(filterProvince)', function(data){
                category = data.value;
                categoryName = data.elem[data.elem.selectedIndex].text;
                $('.provincecode').val(category);
                $('.provincename').val(categoryName);
                $("#city").html('');
                $.ajax({
                    url : "{{url('/api/basequery/city')}}",
                    data : {area_code:category},
                    type : 'get',
                    success : function(data) {
                        //console.log(data);
                        var optionStr = "";
                        for(var i=0;i<data.data.length;i++){
                            optionStr += "<option value='" + data.data[i].area_code + "'>" + data.data[i].area_name + "</option>";
                        }
                        $("#city").append('<option value="">请选择市</option>'+optionStr);
                        layui.form.render('select');
                    },
                    error : function(data) {
                        alert('查找板块报错');
                    }
                });
                //执行重载
                table.reload('test-table-page', {
                    where: {
                        province_code:$('.provincecode').val(),
                        city_code:$('.citycode').val(),
                        area_code:$('.areacode').val()
                    }
                    ,page: {
                        curr: 1
                    }
                });
            });
            form.on('select(filterCity)', function(data){
                category = data.value;
                categoryName = data.elem[data.elem.selectedIndex].text;
                $('.citycode').val(category);
                $('.cityname').val(categoryName);
                $("#area").html('');
                $.ajax({
                    url : "{{url('/api/basequery/city')}}",
                    data : {area_code:category},
                    type : 'get',
                    success : function(data) {
//            console.log(data);
                        var optionStr = "";
                        for(var i=0;i<data.data.length;i++){
                            optionStr += "<option value='" + data.data[i].area_code + "'>" + data.data[i].area_name + "</option>";
                        }
                        $("#area").append('<option value="">请选择县/区</option>'+optionStr);
                        layui.form.render('select');
                    },
                    error : function(data) {
                        alert('查找板块报错');
                    }
                });

                //执行重载
                table.reload('test-table-page', {
                    where: {
                        province_code:$('.provincecode').val(),
                        city_code:$('.citycode').val(),
                        area_code:$('.areacode').val()
                    }
                    ,page: {
                        p: 1 //重新从第 1 页开始
                    }
                });
            });
            form.on('select(filterArea)', function(data){
                category = data.value;
                categoryName = data.elem[data.elem.selectedIndex].text;
                $('.areacode').val(category);
                $('.areaname').val(categoryName);
                //执行重载
                table.reload('test-table-page', {
                    where: {
                        province_code:$('.provincecode').val(),
                        city_code:$('.citycode').val(),
                        area_code:$('.areacode').val()
                    }
                    ,page: {
                        curr: 1
                    }
                });
            });
            // 省市区end-------------------------------

            // 选择业务员
            form.on('select(agent)', function(data){
                var user_id = data.value;
                $('.user_id').val(user_id);
                //执行重载
                table.reload('test-table-page', {
                    where: {
                        user_id:$('.user_id').val()
                    }
                    ,page: {
                        curr: 1
                    }
                });
            });

            // 选择审核状态
            form.on('select(status)', function(data){
                var status = data.value;
                $('.status').val(status);
                //执行重载
                table.reload('test-table-page', {
                    where: {
                        status:$('.status').val()
                    }
                    ,page: {
                        curr: 1
                    }
                });
            });

            // 选择开关闭
            form.on('select(open)', function(data){
                var open_id = data.value;
                $('.open_id').val(open_id);
                if(open_id == 0){
                    $('.close').show();
                    $('.open').hide();
                }else{
                    $('.close').hide();
                    $('.open').show();
                }
                //执行重载
                table.reload('test-table-page', {
                    where: {
                        is_close:$('.open_id').val()
                    }
                    ,page: {
                        curr: 1
                    }
                });
            });

            // 选择是否删除
            form.on('select(del)', function(data){
                var del_id = data.value;
                $('.del_id').val(del_id);
                if(del_id == 0){
                    $('.del').show();
                    $('.recover').hide();
                }else{
                    $('.del').hide();
                    $('.recover').show();
                }
                //执行重载
                table.reload('test-table-page', {
                    where: {
                        is_delete:$('.del_id').val()
                    }
                    ,page: {
                        curr: 1
                    }
                });
            });

            //监听搜索
            form.on('submit(LAY-app-contlist-search)', function(data){
                var obj = data.field;
                //console.log(obj);
                var store_name = data.field.schoolname;
                var store_short_name = data.field.store_short_name;
                var search_phone = data.field.search_phone;
                //console.log(data);
                //执行重载
                table.reload('test-table-page', {
                    page: {
                        curr: 1
                    },
                    where: {
                        store_name:store_name,
                        store_short_name:store_short_name,
                        phone: search_phone,
                        is_incoming:$('#is_incoming').val(),
                        is_quota:$('#is_quota').val()
                    }
                });
            });

            //监听搜索
            form.on('submit(LAY-app-contlist-phone)', function(data){
                var search_phone = data.field.search_phone;
                //执行重载
                table.reload('test-table-page', {
                    page: {
                        curr: 1
                    },
                    where: {
                        phone: search_phone
                    }
                });
            });

            //监听搜索
            form.on('submit(LAY-app-contlist-exprots)', function(data){
                var obj = data.field;
                var is_quota = $('#is_quota').val()
                layer.confirm('确定导出吗？', function(index) {
                    window.location.href="{{url('/api/export/export_stores')}}"+'?token='+token+'&is_quota='+is_quota;
                });
            });

            // 删除
            var active = {
                batchdel: function(){
                    var checkStatus = table.checkStatus('test-table-page')
                        ,checkData = checkStatus.data; //得到选中的数据
                    var arrs=[];

                    for(var i=0;i<checkData.length;i++){
                        arrs.push(checkData[i].store_id);
                    }
                    var store_id=arrs.join();

                    if(checkData.length === 0){
                        return layer.msg('请选择门店');
                    }
                    layer.confirm('确定删除吗？', function(index) {
                        $.post("{{url('/api/user/del_store')}}",
                            {
                                token:token
                                ,store_id:arrs.join()
                            },function(res){
//                console.log(res);
                                if(res.status==1){
                                    layer.msg(res.message, {
                                        offset: '50px'
                                        ,icon: 1
                                        ,time: 1000
                                    },function(){
                                        window.location.reload();
                                    });
                                }else{
                                    layer.msg(res.message, {
                                        offset: '50px'
                                        ,icon: 2
                                        ,time: 2000
                                    });
                                }
                            },"json");
                    });
                }
            };

            // 恢复
            var actives = {
                recover: function(){
                    var checkStatus = table.checkStatus('test-table-page')
                        ,checkData = checkStatus.data; //得到选中的数据
                    //console.log(checkData);
                    var arrs=[];

                    for(var i=0;i<checkData.length;i++){
                        arrs.push(checkData[i].store_id);
                    }
                    var store_id=arrs.join();
                    //console.log(arrs.join());

                    if(checkData.length === 0){
                        return layer.msg('请选择门店');
                    }

                    layer.confirm('确定恢复吗？', function(index) {
                        $.post("{{url('/api/user/rec_store')}}",
                            {
                                token:token
                                ,store_id:arrs.join()
                            },function(res){
                                //console.log(res);
                                if(res.status==1){
                                    layer.msg(res.message, {
                                        offset: '50px'
                                        ,icon: 1
                                        ,time: 1000
                                    },function(){
                                        window.location.reload();
                                    });
                                }else{
                                    layer.msg(res.message, {
                                        offset: '50px'
                                        ,icon: 2
                                        ,time: 2000
                                    });
                                }
                            },"json");
                    });
                }
            };

            // 关闭
            var activet = {
                batchdelclose: function(){
                    var checkStatus = table.checkStatus('test-table-page')
                        ,checkData = checkStatus.data; //得到选中的数据
                    //console.log(checkData);
                    var arrs=[];

                    for(var i=0;i<checkData.length;i++){
                        arrs.push(checkData[i].store_id);
                    }
                    var store_id=arrs.join();
                    //console.log(arrs.join());

                    if(checkData.length === 0){
                        return layer.msg('请选择门店');
                    }

                    layer.confirm('确定关闭门店吗？', function(index) {
                        $.post("{{url('/api/user/col_store')}}",
                            {
                                token:token,
                                store_id:arrs.join()
                            },function(res){
//                console.log(res);
                                if(res.status==1){
                                    layer.msg(res.message, {
                                        offset: '50px'
                                        ,icon: 1
                                        ,time: 1000
                                    },function(){
                                        window.location.reload();
                                    });
                                }else{
                                    layer.msg(res.message, {
                                        offset: '50px'
                                        ,icon: 2
                                        ,time: 2000
                                    });
                                }
                            },"json");
                    });
                }
            };

            // 开启
            var activets = {
                batchdelopen: function(){
                    var checkStatus = table.checkStatus('test-table-page')
                        ,checkData = checkStatus.data; //得到选中的数据
                    //            console.log(checkData);
                    var arrs=[];

                    for(var i=0;i<checkData.length;i++){
                        arrs.push(checkData[i].store_id);
                    }
                    var store_id=arrs.join();
                    //            console.log(arrs.join());

                    if(checkData.length === 0){
                        return layer.msg('请选择门店');
                    }

                    layer.confirm('确定开启门店吗？', function(index) {

                        $.post("{{url('/api/user/ope_store')}}",
                            {
                                token:token,
                                store_id:arrs.join()

                            },function(res){
                                console.log(res);
                                if(res.status==1){
                                    layer.msg(res.message, {
                                        offset: '50px'
                                        ,icon: 1
                                        ,time: 1000
                                    },function(){
                                        window.location.reload();
                                    });
                                }else{
                                    layer.msg(res.message, {
                                        offset: '50px'
                                        ,icon: 2
                                        ,time: 2000
                                    });
                                }
                            },"json");

                    });
                }
            };

            // 彻底删除
            var activedel = {
                // batchdeltotaldel: function(){
                // var checkStatus = table.checkStatus('test-table-page')
                // ,checkData = checkStatus.data; //得到选中的数据
                // //            console.log(checkData);
                // var arrs=[];

                // for(var i=0;i<checkData.length;i++){
                // arrs.push(checkData[i].store_id);
                // }
                // var store_id=arrs.join();
                // console.log(arrs.join());

                // if(checkData.length === 0){
                // return layer.msg('请选择门店');
                // }
                // layer.confirm('清除商户资料和交易数据不可恢复', function(index) {

                // $.post("{{url('/api/user/clear_store')}}",
                // {
                // token:token,
                // store_id:arrs.join()

                // },function(res){
                // console.log(res);
                // if(res.status==1){
                // layer.msg(res.message, {
                // offset: '50px'
                // ,icon: 1
                // ,time: 1000
                // },function(){
                // window.location.reload();
                // });
                // }else{
                // layer.msg(res.message, {
                // offset: '50px'
                // ,icon: 2
                // ,time: 2000
                // });
                // }
                // },"json");

                // });
                // }
            };

            // 添加门店转移
            var activett = {
                transfer: function(){
                    var checkStatus = table.checkStatus('test-table-page')
                        ,checkData = checkStatus.data; //得到选中的数据
                    //            console.log(checkData);
                    var arrtransfer = [];
                    var arrtransfername = [];

                    for(var i=0;i<checkData.length;i++){
                        arrtransfer.push(checkData[i].store_id);
                        arrtransfername.push(checkData[i].store_name);
                    }
                    var store_id=arrtransfer.join();
                    var store_name=arrtransfername.join();
                    //            console.log(arrtransfer.join());
                    //            console.log(arrtransfername.join());
                    localStorage.setItem('js_add_store_id', arrtransfer.join());
                    localStorage.setItem('js_add_store_name', arrtransfername.join());


                    if(checkData.length === 0){
                        return layer.msg('请选择门店');
                    }
                    // else{

                    //   // $('.addstoretransfer').attr('lay-href',"{{url('/user/addstoretransfer?store_id=')}}"+store_id+'&store_name='+store_name);
                    // }


                }
            };

            $('.layui-btn.layuiadmin-btn-forum-list').on('click', function(){
                var type = $(this).data('type');
                //          console.log(type);
                active[type] ? active[type].call(this) : '';
                actives[type] ? actives[type].call(this) : '';
                activet[type] ? activet[type].call(this) : '';
                activets[type] ? activets[type].call(this) : '';
                activets[type] ? activets[type].call(this) : '';
                activett[type] ? activett[type].call(this) : '';
                activedel[type] ? activedel[type].call(this) : '';
            });

            $('.closestore').click(function(){
                $("input:radio[name='sex']:checked").each(function() { // 遍历name=standard选中的多选框的值
                    $.post("{{url('/api/user/check_store')}}",
                        {
                            token:token,
                            store_id:$('.shenhe_store').val(),
                            status:$(this).val(),
                            status_desc:$('.textarea').val()

                        },function(res){
                            if(res.status==1){
                                layer.msg(res.message, {
                                    offset: '50px'
                                    ,icon: 1
                                    ,time: 3000
                                },function(){
                                    window.location.reload();
                                });

                            }else{
                                layer.msg(res.message, {
                                    offset: '50px'
                                    ,icon: 2
                                    ,time: 3000
                                });
                            }
                        },"json");
                });
                $('#edit_shenhe').css('display', 'none');
            });

            $('.ratastore').click(function(){
                $.post("{{url('/api/user/rata_store')}}",{
                    token:token,
                    store_id:$('.rata_store').val(),
                    storerata:$('.storerata').val(),
                    basicrata:$('.basicrata').val(),
                    withuser:$('.withuser').val()
                },function(res){
                    if(res.status==1){
                        layer.msg(res.message, {
                            offset: '50px'
                            ,icon: 1
                            ,time: 3000
                        },function(){

                        });
                    }else{
                        layer.msg(res.message, {
                            offset: '50px'
                            ,icon: 2
                            ,time: 3000
                        });
                    }
                },"json");
                $('#edit_rata').css('display', 'none');
            });

            $('.commitApply').click(function(){
                $.post("{{url('/api/glow/certification')}}",{
                    token:token,
                    store_id: $('.rata_store').val(),
                    contactName: $('.contactName').val(),
                    phoneNumber: $('.phoneNumber').val(),
                    contactIdNo: $('.contactIdNo').val()
                },function(res){
                    $('.commitApply').css('display', 'none');
                    $('.queryApplyInfo').css('display', 'block');
                    $('.backApplyBill').css('display', 'block');
                    if(res.status == 1){

                        layer.msg(res.message, {
                            offset: '50px'
                            ,icon: 1
                            ,time: 3000
                            // },function(){
                            //     window.location.reload();
                        });
                    }else{
                        layer.msg(res.message, {
                            offset: '50px'
                            ,icon: 2
                            ,time: 3000
                        });
                    }
                },"json");
                $('#edit_rata').css('display', 'none');
            });

            $('.queryApplyInfo').click(function(){
                $.post("{{url('/api/glow/queryApplyInfo')}}",{
                    token:token,
                    store_id: $('.rata_store').val(),
                    contactName: $('.contactName').val(),
                    phoneNumber: $('.phoneNumber').val(),
                    contactIdNo: $('.contactIdNo').val()
                }, function(res){
                    // $('.commitApply').css('display', 'none');
                    // $('.queryApplyInfo').css('display', 'block');
                    if(res.status == 1){

                        // var img = res.data
                        // console.log(img)
                        $('.queryApplyInfo_img').html('');
                        $('.queryApplyInfo_img').qrcode(res.data);

                        // $('.queryApplyInfo_img').attr('src', res.data);

                        layer.msg(res.message, {
                            offset: '50px'
                            ,icon: 1
                            ,time: 3000
                            // },function(){
                            //     window.location.reload();
                        });
                    }else{
                        layer.msg(res.message, {
                            offset: '50px'
                            ,icon: 2
                            ,time: 3000
                        });
                    }
                },"json");
                $('#edit_rata').css('display', 'none');
            });

            $('.backApplyBill').click(function(){
                $.post("{{url('/api/glow/backApplyBill')}}",{
                    token:token,
                    store_id: $('.rata_store').val(),
                    contactName: $('.contactName').val(),
                    phoneNumber: $('.phoneNumber').val(),
                    contactIdNo: $('.contactIdNo').val()
                }, function(res){
                    // $('.commitApply').css('display', 'none');
                    // $('.queryApplyInfo').css('display', 'block');
                    if(res.status == 1){
                        layer.msg(res.message, {
                            offset: '50px'
                            ,icon: 1
                            ,time: 3000
                            // },function(){
                            //     window.location.reload();
                        });
                    }else{
                        layer.msg(res.message, {
                            offset: '50px'
                            ,icon: 2
                            ,time: 3000
                        });
                    }
                },"json");
                $('#edit_rata').css('display', 'none');
            });

            $('.addstore').click(function(){
                $(this).attr('lay-href',"{{url('/user/editstore?0')}}");
            });

            $('.addstoretransfer').click(function(){
                $(this).attr('lay-href',"{{url('/user/addstoretransfer?store_id=')}}"+$('.js_add_store_id').val()+'&store_name='+$('.js_add_store_name').val());
            });

            //碰一碰设备列表
            $('#pengyipeng').click(function(){
                $('#pengyipeng').attr('lay-href',"{{url('/user/devicelistpyp?id=')}}"+$('.js_store_id').val());
            })

            // 门店绑定业务员
            var worker_list = [];//业务员列表
            $('.bindWorker').click(function(){
                var user_id = $('.js_store_user_id').val()
                $("#bindWorkerModal .workerSel").html('')
                $.ajax({
                    url : "{{url('/api/v2/incoming/Worker/select')}}",
                    data : {token:token,user_id:user_id,page:1,pagesize:1000},
                    type : 'get',
                    dataType:'json',
                    success : function(data) {
                        var optionStr = "";
                        worker_list = data.data || [];
                        for(var i=0;i<data.data.length;i++){
                            optionStr += "<option value='" + data.data[i].id + "'>"
                            + data.data[i].name + "</option>";
                        }
                        $("#bindWorkerModal .workerSel").append('<option value="">请选择</option>'+optionStr);
                        layui.form.render('select');
                    },
                    error : function(data) {
                        alert('查找板块报错');
                    }
                });
                layer.open({
                    type: 1,
                    title: '关联业务员',
                    closeBtn: 1,
                    area: '522px',
                    skin: 'layui-layer-nobg', //没有背景色
                    shadeClose: true,
                    content: $('#bindWorkerModal')
                });
            })
            var worder_phone;
            form.on('select(workerSel)', function(data){
                let value = data.value;
                let findindex = worker_list.findIndex(ele=>ele.id == value);
                if(findindex > -1){
                    worder_phone = worker_list[findindex].phone;
                }
            });
            $(".bindWorkerConfirm").click(function(){
                let worker_id = $('.workerSel').val()
                if(worker_id){
                    let params = {
                        token:token,
                        worker_id,
                        phone:worder_phone,
                        store_id:$('.js_store_id').val(),
                    }
                    $.post("{{url('/api/v2/incoming/Worker/bind')}}",
                    params,function(res){
                        if(res.status == 1){
                            layer.msg('绑定成功', {
                                offset: '50px'
                                ,icon: 1
                                ,time: 3000
                            },function(){
                                layer.closeAll()
                                //window.location.reload();
                            });
                        }else{
                            layer.msg(res.message, {
                                offset: '50px'
                                ,icon: 2
                                ,time: 2000
                            });
                        }
                    },"json");
                }
            })

            // 获取码信息
            var canvasLoading;
            var qrcodeurl;
            var wxcodeurl;
            var alipaycodeurl;
            function getThreeCode(){
                canvasLoading = layer.msg('加载中..', {
                    icon: 16
                    ,shade: 0.3
                    ,time: false
                });
                $.get("{{url('/api/v2/incoming/Upload/getThreeQrCodePc')}}",
                    {
                        token:token
                        ,store_id:$('.js_store_id').val()
                        ,is_pc:1
                    },
                    function(res){
                        if(res.status==1){
                            let qrcode = res.store_qr || '';
                            let wxcode = res.wx_qr || '';
                            let alipaycode = res.zfb_qr || '';
                            // if(qrcode){
                            //     $('#wxAliRzcode #qrcodeImg').show()
                            //     $('#wxAliRzcode #qrcodeImgUrl').attr('src',qrcode);
                            //     $('#wxAliRzcode .downImg').show()
                            //     qrcodeurl = qrcode
                            // }
                            if(wxcode){
                                $('#wxAliRzcode #wxcodeImg').show()
                                $('#wxAliRzcode #wxcodeImgUrl').attr('src',wxcode);
                                $('#wxAliRzcode .downWxImg').show()
                                $('#wxAliRzcode .applyCxBtn').show()
                                wxcodeurl = wxcode
                            }
                            if(alipaycode){
                                $('#wxAliRzcode #alipaycodeImg').show()
                                $('#wxAliRzcode #alipaycodeImgUrl').attr('src',alipaycode);
                                $('#wxAliRzcode .downAlipayImg').show()
                                $('#wxAliRzcode .applyCxBtn').show()
                                alipaycodeurl = alipaycode
                            }
                            // if(qrcode && wxcode && alipaycode){
                            //     layer.close(canvasLoading)
                            // }else{
                            //     queryApplyInfoCanvas()
                            // }
                            if(wxcode && alipaycode){
                                layer.close(canvasLoading)
                            }else{
                                queryApplyInfoCanvas()
                            }
                        }else if(res.status==2){
                            layer.msg(res.message, {
                                offset: '50px'
                                ,icon: 2
                                ,time: 3000
                            });
                        }
                    },"json");
            }
            function queryApplyInfoCanvas(){
                $.get("{{url('/api/v2/Vbill/Authentication/queryApplyInfo')}}",
                {
                    token:token
                    ,store_id:$('.js_store_id').val()
                },
                function(res){
                    if(res.status==1){
                        let data = res.data;
                        // if(data.store_qr && !qrcodeurl){
                        //     $('#wxAliRzcode #code').html('');
                        //     $('#wxAliRzcode #code').qrcode(data.store_qr);
                        //     creatPoster()
                        // }
                        // weixin
                        if(data.wx_auth == -1){
                            $('.applyRzBtn').show();
                            $('.wxResult').show()
                            $('.bohuiResult').html(data.wx_auth_reason)
                            // if(qrcodeurl && !wxcodeurl){
                            //     layer.close(canvasLoading)
                            // }
                            if( !wxcodeurl){
                                layer.close(canvasLoading)
                            }
                        }else if(data.wx_auth == 0 ||data.wx_auth == 1){
                            $('.applyRzBtn').show();
                            $('.wxNoOpenText').html(data.wx_auth_reason || '审核中')
                            $('.wxNoOPenResult').show()
                            // if(qrcodeurl && !wxcodeurl){
                            //     layer.close(canvasLoading)
                            // }
                             if( !wxcodeurl){
                                layer.close(canvasLoading)
                            }
                        }else if(data.wx_auth == -2){
                            $('.applyRzBtn').hide();
                            $('.wxNoOPenResult').show()
                            $('.wxNoOpenText').html(data.wx_auth_reason)
                            // if(qrcodeurl && !wxcodeurl){
                            //     layer.close(canvasLoading)
                            // }
                             if(!wxcodeurl){
                                layer.close(canvasLoading)
                            }
                            
                        }else if(data.wx_auth == 2){
                            if(!wxcodeurl){
                                let wxurl = data.wx_url;
                                let wx_mch_id = data.weixin_mch_id || '';
                                creatPosterWx(wxurl,wx_mch_id)
                                $('.applyCxBtn').show()
                                $('.downWxImg').show()
                                $('.applyRzBtn').hide();
                                $('.wxNoOPenResult').hide()
                                $('.wxNoOpenText').html('')
                            }
                            
                        }
                        // 支付宝
                        if(data.zfb_auth == -1){
                            $('.applyRzBtn').show();
                            $('.alipayResult').show()
                            $('.alipaybohuiResult').html(data.zfb_auth_reason)
                            // if(qrcodeurl && !alipaycodeurl){
                            //     layer.close(canvasLoading)
                            // }
                             if(!alipaycodeurl){
                                layer.close(canvasLoading)
                            }
                        }else if(data.zfb_auth == 0 ||data.zfb_auth == 1){
                            $('.applyRzBtn').show();
                            $('.alipayNoOpenText').html(data.zfb_auth_reason || '审核中')
                            $('.alipayNoOPenResult').show()
                            // if(qrcodeurl && !alipaycodeurl){
                            //     layer.close(canvasLoading)
                            // }
                            if(!alipaycodeurl){
                                layer.close(canvasLoading)
                            }
                        }else if(data.zfb_auth == -2){
                            $('.alipayNoOpenText').html(data.zfb_auth_reason)
                            $('.alipayNoOPenResult').show()
                            // if(qrcodeurl && !alipaycodeurl){
                            //     layer.close(canvasLoading)
                            // }
                            if(!alipaycodeurl){
                                layer.close(canvasLoading)
                            }
                        }else if(data.zfb_auth == 2){
                            if(!alipaycodeurl){
                                let zfburl = data.zfb_url;
                                let zfb_mch_id = data.alipay_mch_id || '';
                                creatPosterAlipay(zfburl,zfb_mch_id)
                                $('.applyCxBtn').show()
                                $('.downAlipayImg').show()
                                $('.applyRzBtn').hide();
                                $('.alipayNoOPenResult').hide()
                                $('.alipayNoOpenText').html('')
                            }
                            
                        }
                    }else if(res.status==2){
                        layer.msg(res.message, {
                            offset: '50px'
                            ,icon: 2
                            ,time: 3000
                        });
                    }
                },"json");
            }
            // 收款码模板生成
            function creatPoster(){
                var canvas2 = document.getElementById('qrcode-canvas');
                var ctx = canvas2.getContext('2d');
                canvas2.width = 413;
                canvas2.height = 630;
                ctx.fillStyle = 'white';
                ctx.fillRect(0, 0, canvas2.width, canvas2.height);
                let filePath = "{{asset('/school/images/pcCodeTemplet.png')}}"
                var img = new Image()
                // img.crossOrigin = 'Anonymous';
                img.src = filePath;
                //文件加载完毕
                img.onload = function () {
                    ctx.drawImage(img, 0, 0, canvas2.width, 630);

                    //绘制logo
                    let filePathlogo = "{{asset('/school/images/logo-black.png')}}"
                    var imglogo = new Image()
                    imglogo.src = filePathlogo;
                    imglogo.onload = function () {
                        ctx.drawImage(imglogo, 2, 0, 65, 60);
                        // 绘制皖付通
                        // 设置加粗字体样式
                        ctx.font = `bold 20px Arial`;
                        ctx.fillStyle = '#fff';
                        ctx.fillText('皖付通', 62, 38);
                         // 获取canvas元素
                        const canvasCode = $('#code canvas')[0];
                        // 将canvas转换为base64图片地址
                        const base64 = canvasCode.toDataURL('image/png');
                        var img2 = new Image()
                        img2.crossOrigin = 'Anonymous';
                        img2.src = base64;
                        //文件加载完毕
                        img2.onload = function () {
                            ctx.drawImage(img2, 102, 219, 202, 202);
                            //绘制门店名称
                            let store_short_name = $('#wxAliRzcode .store_short_name').val()
                            let storeFontSize = 42;
                            ctx.textAlign = 'center';
                            // 设置加粗字体样式
                            ctx.font = `bold ${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                            // 测量文字宽度
                            let textWidth = ctx.measureText(store_short_name).width;

                            // 调整字号直到文字适合宽度或达到最小字号
                            while (textWidth > canvas2.width && storeFontSize > 12) {
                                storeFontSize--;
                                ctx.font = `bold ${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                                textWidth = ctx.measureText(store_short_name).width;
                            }
                            // 计算绘制位置
                            let x = canvas2.width / 2;
                            ctx.fillStyle = '#fff';
                            ctx.fillText(store_short_name, x, 102);

                            uploadImg(canvas2,'store_qr')
                        }
                    }

                }
               
            }
            function creatPosterWx(qrurl,mch_id){
				let canvasid = 'wxcode-canvas';
				let bgimg = "{{asset('/school/images/wxrenzheng.jpg')}}"
				var canvaswx = document.getElementById('wxcode-canvas');
                var ctxwx = canvaswx.getContext('2d');
                // 绘制背景图
                ctxwx.fillStyle = '#fff';
                // 填充整个Canvas
                canvaswx.width = 390;
                canvaswx.height = 610;
                let width = 390;
                let height = 610;
                ctxwx.fillRect(0, 0, canvaswx.width, canvaswx.height);
                var imgwxapl = new Image()
                // img.crossOrigin = 'Anonymous';
                imgwxapl.src = bgimg;
                //文件加载完毕
                imgwxapl.onload = function () {
                    ctxwx.drawImage(imgwxapl, 0, 0, width, height);
                    // 绘制简称
                    let store_name = '注册名称：' + $('.storename').html();
                    let storeFontSize = 22;
                    ctxwx.textAlign = 'center';
                    // 设置加粗字体样式
                    ctxwx.font = `${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                    // 测量文字宽度
                    let textWidthst = ctxwx.measureText(store_name).width;
                
                    // 调整字号直到文字适合宽度或达到最小字号
                    while (textWidthst > width && storeFontSize > 12) {
                        storeFontSize--;
                        ctxwx.font = `${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                        textWidthst = ctxwx.measureText(store_name).width;
                    }
                    // 计算绘制位置
                    let storenameX = width / 2;
                    ctxwx.fillStyle = '#212121';
                    ctxwx.fillText(store_name, storenameX, 500);
                    // 绘制商户名称
                    let store_short_name ='商户名称：' +  $('#wxAliRzcode .store_short_name').val();
                    storeFontSize = 22;
                    // 测量文字宽度
                    let textWidth = ctxwx.measureText(store_short_name).width;
                                    
                    // 调整字号直到文字适合宽度或达到最小字号
                    while (textWidth > width && storeFontSize > 12) {
                        storeFontSize--;
                        ctxwx.font = `${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                        textWidth = ctxwx.measureText(store_short_name).width;
                    }
                    // 计算绘制位置
                    let shortx = width / 2;
                    ctxwx.fillStyle = '#212121';
                    ctxwx.fillText(store_short_name, shortx, 540);
                    // 绘制子商户号
                    let mchid = mch_id
                    let sunmchid ='子商户号：' + mchid;
                    storeFontSize = 22
                    // 测量文字宽度
                    let textWidthmch = ctxwx.measureText(sunmchid).width;
                                    
                    // 调整字号直到文字适合宽度或达到最小字号
                    while (textWidthmch > width && storeFontSize > 12) {
                        storeFontSize--;
                        ctxwx.font = `bold ${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                        textWidthmch = ctxwx.measureText(sunmchid).width;
                    }
                    // 计算绘制位置
                    let mchidx = width / 2;
                    ctxwx.fillStyle = '#212121';
                    ctxwx.fillText(sunmchid, mchidx, 580);
                    // 绘制二维码
                    var img3 = new Image()
                    img3.crossOrigin = 'Anonymous';
                    img3.src = qrurl;
                    //文件加载完毕
                    img3.onload = function () {
                        ctxwx.drawImage(img3, 94, 210, 200, 200);
                        uploadImg(canvaswx,'wx_qr')
                    }
                }
            }
             function creatPosterAlipay(qrurl,mch_id){
				let bgimg = "{{asset('/school/images/alipayrenzheng.jpg')}}"
				var canvasalipay = document.getElementById('alipaycode-canvas');
                var ctxalipay = canvasalipay.getContext('2d');
                // 绘制背景图
                ctxalipay.fillStyle = '#fff';
                // 填充整个Canvas
                canvasalipay.width = 390;
                canvasalipay.height = 610;
                let width = 390;
                let height = 610;
                ctxalipay.fillRect(0, 0, canvasalipay.width, canvasalipay.height);
                var imgwxapl = new Image()
                // img.crossOrigin = 'Anonymous';
                imgwxapl.src = bgimg;
                //文件加载完毕
                imgwxapl.onload = function () {
                    ctxalipay.drawImage(imgwxapl, 0, 0, width, height);
                    // 绘制简称
                    let store_name = '注册名称：' + $('.storename').html();
                    let storeFontSize = 22;
                    ctxalipay.textAlign = 'center';
                    // 设置加粗字体样式
                    ctxalipay.font = `${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                    // 测量文字宽度
                    let textWidthst = ctxalipay.measureText(store_name).width;
                
                    // 调整字号直到文字适合宽度或达到最小字号
                    while (textWidthst > width && storeFontSize > 12) {
                        storeFontSize--;
                        ctxalipay.font = `${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                        textWidthst = ctxalipay.measureText(store_name).width;
                    }
                    // 计算绘制位置
                    let storenameX = width / 2;
                    ctxalipay.fillStyle = '#212121';
                    ctxalipay.fillText(store_name, storenameX, 500);
                    // 绘制商户名称
                    let store_short_name ='商户名称：' +  $('#wxAliRzcode .store_short_name').val();
                    storeFontSize = 22;
                    // 测量文字宽度
                    let textWidth = ctxalipay.measureText(store_short_name).width;
                                    
                    // 调整字号直到文字适合宽度或达到最小字号
                    while (textWidth > width && storeFontSize > 12) {
                        storeFontSize--;
                        ctxalipay.font = `${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                        textWidth = ctxalipay.measureText(store_short_name).width;
                    }
                    // 计算绘制位置
                    let shortx = width / 2;
                    ctxalipay.fillStyle = '#212121';
                    ctxalipay.fillText(store_short_name, shortx, 540);
                    // 绘制子商户号
                    let mchid = mch_id
                    let sunmchid ='子商户号：' + mchid;
                    storeFontSize = 22
                    // 测量文字宽度
                    let textWidthmch = ctxalipay.measureText(sunmchid).width;
                                    
                    // 调整字号直到文字适合宽度或达到最小字号
                    while (textWidthmch > width && storeFontSize > 12) {
                        storeFontSize--;
                        ctxalipay.font = `bold ${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                        textWidthmch = ctxalipay.measureText(sunmchid).width;
                    }
                    // 计算绘制位置
                    let mchidx = width / 2;
                    ctxalipay.fillStyle = '#212121';
                    ctxalipay.fillText(sunmchid, mchidx, 580);
                    // 绘制二维码
                    var img3 = new Image()
                    img3.crossOrigin = 'Anonymous';
                    img3.src = qrurl;
                    //文件加载完毕
                    img3.onload = function () {
                        ctxalipay.drawImage(img3, 94, 210, 200, 200);
                        uploadImg(canvasalipay,'zfb_qr')
                    }
                }
            }
            
            function uploadImg(canvas,typess){
                let store_id = $('.js_store_id').val();
                // 将 Canvas 转换为 Blob 对象
                canvas.toBlob(function(blob) {
                    // 创建 FormData
                    var formData = new FormData();
                    console.log(blob,'blob')
                    formData.append(typess, blob,`${store_id}.png`); // 第三个参数是文件名
                    formData.append('token', token); // 可添加其他参数
                    formData.append('store_id', store_id); // 可添加其他参数

                    // 使用 Layui 的 AJAX 上传
                    $.ajax({
                    url: '/api/v2/incoming/Upload/uploadThreeQrCodePc',
                    type: 'POST',
                    data: formData,
                    processData: false, // 必须：禁止 jQuery 处理数据
                    contentType: false, // 必须：不设置 Content-Type
                    success: function(res) {
                        console.log('上传成功');
                        console.log('服务器响应:', res);
                        // getThreeCode()
                        setTimeout(() => {
                            $.get("{{url('/api/v2/incoming/Upload/getThreeQrCodePc')}}",
                            {
                                token:token
                                ,store_id:store_id
                                ,is_pc:1
                            },
                            function(res){
                                if(res.status==1){
                                    qrcodeurl = res.store_qr || '';
                                    wxcodeurl = res.wx_qr || '';
                                    alipaycodeurl = res.zfb_qr || '';
                                    // if(qrcodeurl){
                                    //     $('#wxAliRzcode #qrcodeImg').show()
                                    //     $('#wxAliRzcode #qrcodeImgUrl').attr('src',qrcodeurl);
                                    //     $('#wxAliRzcode .downImg').show()
                                    // }
                                    if(wxcodeurl){
                                        $('#wxAliRzcode #wxcodeImg').show()
                                        $('#wxAliRzcode #wxcodeImgUrl').attr('src',wxcodeurl);
                                        $('#wxAliRzcode .downWxImg').show()
                                        $('#wxAliRzcode .applyCxBtn').show()
                                    }
                                    if(alipaycodeurl){
                                        $('#wxAliRzcode #alipaycodeImg').show()
                                        $('#wxAliRzcode #alipaycodeImgUrl').attr('src',alipaycodeurl);
                                        $('#wxAliRzcode .downAlipayImg').show()
                                        $('#wxAliRzcode .applyCxBtn').show()
                                    }
                                    setTimeout(() => {
                                        layer.close(canvasLoading)
                                    }, 1000);
                                    
                                
                                }else if(res.status==2){
                                    layer.msg(res.message, {
                                        offset: '50px'
                                        ,icon: 2
                                        ,time: 3000
                                    });
                                }
                            },"json");
                        }, 2000);
                        
                    },
                    error: function(err) {
                        console.log('上传失败');
                        console.error('上传错误:', err);
                    }
                    });
                }); // 指定图片格式为 PNG
            }
            $('.applyRzBtn').click(function(){ //一键认证
                canvasLoading = layer.msg('加载中..', {
                    icon: 16
                    ,shade: 0.3
                    ,time: false
                });
                queryApplyInfoCanvas()
            })
            $('.applyCxBtn').click(function(){ //一键撤销
                canvasLoading = layer.msg('加载中..', {
                    icon: 16
                    ,shade: 0.3
                    ,time: false
                });
                $.post("{{url('/api/v2/Vbill/Authentication/backApplyBill')}}",
                    {
                        token:token
                        ,store_id:$('.js_store_id').val()
                    },
                    function(res){
                        if(res.status==1){
                            layer.msg(res.message, {
                                offset: '50px'
                                ,icon: 1
                                ,time: 3000
                            });
                            wxaliCodeReset(true)
                            layer.close(canvasLoading)
                        }else if(res.status==2){
                            layer.msg(res.message, {
                                offset: '50px'
                                ,icon: 2
                                ,time: 3000
                            });
                            layer.close(canvasLoading)
                        }
                    },"json");
            })
            // 保存图片
            $('.downImg').click(function(){
                if(qrcodeurl){
                    layer.confirm('请核对当前图片显示的数据是否正确后再下载', {
                        title: "操作提示",
                        icon: 0,
                        closeBtn: 2,
                        btn: ['确认', '取消'] //可以无限个按钮
                        ,btn3: function(index, layero){
                            //按钮【取消】的回调
                            layer.close(index);
                        }
                        }, function(index, layero){
                            window.location.href=qrcodeurl;
                            layer.close(index);
                    });
                }
            })
            $('.downWxImg').click(function(){
                if(wxcodeurl){
                    layer.confirm('请核对当前图片显示的数据是否正确后再下载', {
                        title: "操作提示",
                        icon: 0,
                        closeBtn: 2,
                        btn: ['确认', '取消'] //可以无限个按钮
                        ,btn3: function(index, layero){
                            //按钮【取消】的回调
                            layer.close(index);
                        }
                        }, function(index, layero){
                            window.location.href=wxcodeurl;
                            layer.close(index);
                    });
                }
            })
            $('.downAlipayImg').click(function(){
                if(alipaycodeurl){
                    layer.confirm('请核对当前图片显示的数据是否正确后再下载', {
                        title: "操作提示",
                        icon: 0,
                        closeBtn: 2,
                        btn: ['确认', '取消'] //可以无限个按钮
                        ,btn3: function(index, layero){
                            //按钮【取消】的回调
                            layer.close(index);
                        }
                        }, function(index, layero){
                            window.location.href=alipaycodeurl;
                            layer.close(index);
                    });
                }
            })
            // 弹框关闭或打开时重置
            function wxaliCodeReset(isReset=false){
                if(isReset == false){
                    $('#wxAliRzcode #qrcodeShow').hide()
                    $('#wxAliRzcode #code').html('')
                    $('#wxAliRzcode #qrcode-canvas').html('')
                    $('#wxAliRzcode #qrcodeImg').hide()
                    $('#wxAliRzcode #qrcodeImgUrl').attr('src','');
                    qrcodeurl = '';
                }
                // 微信
                $('#wxAliRzcode #wxcodeShow').hide()
                $('#wxAliRzcode #wxcode-canvas').html('')
                $('#wxAliRzcode #wxcodeImg').hide()
                $('#wxAliRzcode #wxcodeImgUrl').attr('src','');
                $('.wxResult').hide()
                $('.bohuiResult').html('')
                // $('.wxResult').html('微信驳回原因：')
                $('.wxNoOPenResult').hide()
                $('.wxNoOpenText').html('')
                console.log('wxaliCodeReset-----',)
                // 支付宝
                $('#wxAliRzcode #alipaycodeShow').hide()
                $('#wxAliRzcode #alipaycode-canvas').html('')
                $('#wxAliRzcode #alipaycodeImg').hide()
                $('#wxAliRzcode #alipaycodeImgUrl').attr('src','');
                $('.alipayResult').hide()
                $('.alipaybohuiResult').html('')
                // $('.alipayResult').html('支付宝驳回原因：')
                $('.alipayNoOPenResult').hide()
                $('.alipayNoOpenText').html('')
                // 按钮
                $('#wxAliRzcode .applyRzBtn').hide()
                $('#wxAliRzcode .applyCxBtn').hide()
                $('#wxAliRzcode .downImg').hide()
                $('#wxAliRzcode .downWxImg').hide()
                $('#wxAliRzcode .downAlipayImg').hide()
                if(isReset == true){
                    $('#wxAliRzcode .applyRzBtn').show()
                    $('#wxAliRzcode .downImg').show()
                }
                wxcodeurl = '';
                alipaycodeurl = '';
            }
        });

         // 收款码模板下载
        $('.mobanDown').click(function(){
            var mobanloading = layer.msg('下载中..', {
                icon: 16
                ,shade: 0.3
                ,time: false
            });
            var canvas = document.getElementById('poster-canvas');
            var ctx = canvas.getContext('2d');
            canvas.width = 413;
            canvas.height = 630;
            ctx.fillStyle = 'white';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            let filePath = "{{asset('/school/images/pcCodeTemplet.png')}}"
            var img = new Image()
            // img.crossOrigin = 'Anonymous';
            img.src = filePath;
            //文件加载完毕
            img.onload = function () {
                ctx.drawImage(img, 0, 0, canvas.width, 630);

                //绘制logo
                let filePathlogo = "{{asset('/school/images/logo-black.png')}}"
                var imglogo = new Image()
                imglogo.src = filePathlogo;
                imglogo.onload = function () {
                    ctx.drawImage(imglogo, 2, 0, 65, 60);
                    // 绘制皖付通
                    // 设置加粗字体样式
                    ctx.font = `bold 20px Arial`;
                    ctx.fillStyle = '#fff';
                    ctx.fillText('皖付通', 62, 38);
                        // 获取canvas元素
                    const canvasCode = $('#code canvas')[0];
                    // 将canvas转换为base64图片地址
                    const base64 = canvasCode.toDataURL('image/png');
                    var img2 = new Image()
                    img2.crossOrigin = 'Anonymous';
                    img2.src = base64;
                    //文件加载完毕
                    img2.onload = function () {
                        ctx.drawImage(img2, 102, 219, 202, 202);
                        //绘制门店名称
                        let storename = $('.storename').html();
                        let store_short_name = $('#edit_rate .store_short_name').val()
                        let storeFontSize = 42;
                        ctx.textAlign = 'center';
                        // 设置加粗字体样式
                        ctx.font = `bold ${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                        // 测量文字宽度
                        let textWidth = ctx.measureText(store_short_name).width;

                        // 调整字号直到文字适合宽度或达到最小字号
                        while (textWidth > canvas.width && storeFontSize > 12) {
                            storeFontSize--;
                            ctx.font = `bold ${storeFontSize}px 'Microsoft YaHei', sans-serif`;
                            textWidth = ctx.measureText(store_short_name).width;
                        }
                        // 计算绘制位置
                        let x = canvas.width / 2;
                        ctx.fillStyle = '#fff';
                        ctx.fillText(store_short_name, x, 102);

                        // 下载海报
                        const dataUrl = canvas.toDataURL('image/png');
                        
                        if (dataUrl === 'data:,') {
                            layer.error('请先生成海报');
                            return;
                        }
                        
                        const a = document.createElement('a');
                        a.href = dataUrl;
                        a.download = `${store_short_name}_门店收款码.png`;
                        document.body.appendChild(a);
                        a.click();
                        document.body.removeChild(a);
                        layer.close(mobanloading);
                    }
                }

            }
            
        })
        
        // 被扫测试
        $('.beisaoTest').click(function(){
            layer.open({
                type: 1,
                title: '测试被扫支付',
                closeBtn: 1,
                area: '800px',
                skin: 'layui-layer-nobg', //没有背景色
                shadeClose: true,
                content: $('#beisaoTestModal'),
                end:function(){
                    $('#beisaoTestModal .code').val('')
                    $('#beisaoTestModal .total_amount').val('')
                    $('#beisaoTestModal .returnInfoShow').hide()
                    $('#beisaoTestModal #returnInfo').html('')
                    $('#beisaoTestModal .out_trade_no_select').val('')
                    $('#beisaoTestModal .returnInfoSelShow').hide()
                    $('#beisaoTestModal #returnInfo_select').html('');
                    $('#beisaoTestModal .refund_amount').val('')
                    $('#beisaoTestModal .out_trade_no_refund').val('')
                    $('#beisaoTestModal .refund_no').val('')
                    $('#beisaoTestModal .returnInfoRefShow').hide()
                    $('#beisaoTestModal #returnInfo_refund').html('')
                }
            });
        })

        //被扫测试-支付
        var testPayLoading;
        $('.payConfirm').click(function(){
            if($('#beisaoTestModal .code').val() && $('#beisaoTestModal .total_amount').val()){
                testPayLoading = layer.msg('数据请求中..', {
                    icon: 16
                    ,shade: 0.3
                    ,time: false
                });
                let params = {
                    store_id:$('.js_store_id').val()
                    ,merchant_id:$('.merchant_id').val()
                    ,code:$('#beisaoTestModal .code').val()
                    ,total_amount:$('#beisaoTestModal .total_amount').val()
                    ,device_id:'001'
                    ,device_type:'00'
                }
                let sign = generateSign(params);
                params['sign'] = sign;
                let paramsvalue = JSON.stringify(params)
                $.ajax({
                    url: '/api/devicepay/scan_pay',
                    type: 'POST',
                    data: paramsvalue,
                    contentType: 'application/json', 
                    success: function(res) {
                        layer.close(testPayLoading);
                        console.log(res,'12345----')
                        $('#beisaoTestModal .returnInfoShow').show()
                        $('#beisaoTestModal #returnInfo').html(syntaxHighlight(res));
                    },
                    error: function(err) {
                        console.log(res,'12345----')
                        layer.close(testPayLoading);
                        $('#beisaoTestModal .returnInfoShow').show()
                        $('#beisaoTestModal #returnInfo').html(syntaxHighlight(res));
                    }
                    });
            }else{
                if(!$('#beisaoTestModal .code').val()){
                    layer.msg('请输入付款码！')
                }else{
                    layer.msg('请输入付款金额！')
                }
                
            }
        })

        //被扫测试-查询订单
        $('.selectPayConfirm').click(function(){
            if($('#beisaoTestModal .out_trade_no_select').val()){
                let params = {
                    store_id:$('.js_store_id').val()
                    ,merchant_id:$('.merchant_id').val()
                    ,out_trade_no:$('#beisaoTestModal .out_trade_no_select').val()
                    ,device_id:'001'
                    ,device_type:'00'
                }
                let sign = generateSign(params);
                params['sign'] = sign;
                let paramsvalue = JSON.stringify(params)
                $.post("{{url('/api/devicepay/order_query')}}",
                paramsvalue,
                function(res){
                    $('#beisaoTestModal .returnInfoSelShow').show()
                    $('#beisaoTestModal #returnInfo_select').html(syntaxHighlight(res));
                },"json");
            }else {
                layer.msg('请输入订单号！')
            }
        })
        // 被扫测试-退款
        $('.refundConfirm').click(function(){
            if(!$('#beisaoTestModal .refund_amount').val()){
                layer.msg('请输入退款金额！')
                return false
            }
            if(!$('#beisaoTestModal .out_trade_no_refund').val()){
                layer.msg('请输入订单号！')
                return false
            }
            if(!$('#beisaoTestModal .refund_no').val()){
                layer.msg('请输入退款单号！')
                return false
            }
            let params = {
                store_id:$('.js_store_id').val()
                ,merchant_id:$('.merchant_id').val()
                ,out_trade_no:$('#beisaoTestModal .out_trade_no_refund').val()
                ,refund_amount:$('#beisaoTestModal .refund_amount').val()
                ,refund_no:$('#beisaoTestModal .refund_no').val()
                ,device_id:'001'
                ,device_type:'00'
            }
            let sign = generateSign(params);
            params['sign'] = sign;
            let paramsvalue = JSON.stringify(params)
            $.post("{{url('/api/devicepay/refund')}}",
            paramsvalue,
            function(res){
                $('#beisaoTestModal .returnInfoRefShow').show()
                $('#beisaoTestModal #returnInfo_refund').html(syntaxHighlight(res));
            },"json");
        })
        // 生成签名函数
        function generateSign(params) {
            // 1. 过滤掉sign字段和空值
            const filteredParams = {};
            for (const [k, v] of Object.entries(params)) {
            if (k !== 'sign' && v !== undefined && v !== null && v != '') {
                filteredParams[k] = String(v); // 确保值为字符串
            }
            }
            
            // 2. 按键名升序排序
            const sortedKeys = Object.keys(filteredParams).sort();
            
            // 3. 拼接键值对
            const stringToSign = sortedKeys
            .map(key => `${key}=${filteredParams[key]}`)
            .join('&');
            
            // 4. 拼接密钥
            let key = '&key=88888888'
            const finalString = stringToSign + key;
            
            // 5. 生成MD5签名
            console.log(md5())
            return md5(finalString);
        }

        //JSON高亮
        function syntaxHighlight(json) {
            if (typeof json != 'string') {
                json = JSON.stringify(json, undefined, 2);
            }
            json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
            return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
                var cls = 'number';
                if (/^"/.test(match)) {
                    if (/:$/.test(match)) {
                        cls = 'key';
                    } else {
                        cls = 'string';
                    }
                } else if (/true|false/.test(match)) {
                    cls = 'boolean';
                } else if (/null/.test(match)) {
                    cls = 'null';
                }
                return '<span class="' + cls + '">' + match + '</span>';
            });
        }

    </script>

</body>
</html>





